Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form.KeyPress
Message
General information
Forum:
ASP.NET
Category:
Forms
Title:
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01272436
Message ID:
01272617
Views:
19
Hi,

Don't think that's it. I can get the behavior with a WebBrowser control with no url. I think it is related to the fact that we're dealing with an ActiveX control - seems to take a couple of click on the control before the form level KeyPress starts firing.

I played around with a Button (with TabIndex 0 ) behind the WebBrowser control. That allowed the Form.KeyPress to kick in after the Form was acitvated - but it stops working the first time you click on the WebBrowser :-{

Have you tried the WebBrowser.PreviewKeyDown event instead?

Regards,
Viv

>I've tracked it down to the fact that I am displaying a PDF in the WebBrowser control. Then I thought about what would happend in Internet Explorer, so I dropped a PDF into IR and tried to press F11 (the window should maximize) but nothing happend. I am using IE6 on my dev laptop.
>
>Einar
>
>>Viv,
>>Thanks for testing. I also created a new test form and now I can get the form's keyobard events to fire, but only after I mouse click the webbrowser control on the form. After I click a keyboard button and the keyboard even fire I have to mouse click the webbrowser control again. Is that the behaviour you saw?
>>
>>I tried to access the keyboard events for the WebBrowser control in code (not through the property window) and exceptions were thrown left and right, but I noticed that the WebBrowser control is an ActiveX control, and that might be the reason for my troubles.
>>
>>Einar
>>
>>UPDATE: If I display something in the webbrowser control using the Url property (this.webBrowser1.Url = new Uri(@"c:\einar\1024x768.pdf");) the keyboard events don't fire even after mouse clicking the webbrowser control.
>>
>>>Hmm. WebBrowser control derives from Control and Control has a KeyPress event. Why do you say it WebBrowser doesn't have one? (Just looking at docs - haven't tried it.....)
>>>
>>>UPDATE: Just tried a WebBrowser on a form with KeyPreview true. Form got the KeyPress event just fine. OTOH, you seem to be right - the WebBrowser control doesn't expose the KeyPress event (at least not in the properties window)....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform