.net webbrowser control

Created : 7/11/2022

Question

I am using the webbrowser control in visual studio. I think it is a wrapper around internet explorer. Anyway all is going well I am using it in edit mode however I can't get he document's keydown event to fire (in order to catch ctrl+v) anyone had similar problems with it?

Anyone have a solution?

Questioned by : PeteT

Answer

Indeed the webbrowser control is just a wrapper of the IE browser control. Is your problem that the controls PreviewKeyDown not working? Seems to be working for me as long as the control has focus.

 webBrowser1.PreviewKeyDown += new PreviewKeyDownEventHandler(webBrowser1_PreviewKeyDown);       

....

 private void webBrowser1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
     Console.WriteLine(e.KeyCode.ToString() + "  " + e.Modifiers.ToString());
     if (e.Modifiers == Keys.Control && e.KeyCode == Keys.V) {
         MessageBox.Show("ctrl-v pressed");
     }
 }

but perhaps I am not completely understanding?

Answered by : sbeskur