CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jun 2008
    Posts
    52

    Press a keyboard key

    Hey guys I've been trying to get my web browser to load on a web page on enter but nothing seems to work here's what I'm trying to do:
    Try 1
    Code:
            private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if(e.KeyChar = Keys.Enter)
                {
                    webBrowser1.Navigate(comboBox1.Text);
                }
            }
    VS2008 Compiler error: Cannot implicitly convert type 'System.Windows.Forms.Keys' to 'char'. An explicit conversion exists (are you missing a cast?)

    Try 2
    Code:
            private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                switch (e.KeyChar)
                {
                    case Keys.Enter:
                        webBrowser1.Navigate(comboBox1.Text);
                        break;
                }
            }
    VS2008 Compiler error: Cannot implicitly convert type 'System.Windows.Forms.Keys' to 'char'. An explicit conversion exists (are you missing a cast?)

    Try 3
    Code:
            private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                switch (e.KeyChar)
                {
                    case Keys.Enter.ToString();
                        webBrowser1.Navigate(comboBox1.Text);
                        break;
                }
            }
    VS2008 Compiler error: error CS0029: Cannot implicitly convert type 'string' to 'char'

    Can anyone please please help I've been trying to find a solution for 3 hours now but nothing works
    Last edited by Korupt; July 30th, 2008 at 11:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured