Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
In my project there is a need that when i press the "PgDn" key then next form is open , so please anyone tell me how can i do this.
Posted

I assume it needs to be done when this key is pressed in some form. Override the method System.Windows.Forms.Form.OnKeyDown and use event arguments parameter passed to this method to determine what key is pressed. Here is the problem: usually some form's child control is focused; and it grabs keyboard focus out of the form itself. Activated form rarely has a focus like a control. So, you need to preview events by the form. To do that, set the property System.Windows.Forms.Form.KeyPreview to true.

See:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

Now, keep in mind that if you use this exact key you can greatly confuse your user. PgDown should be reserved for "Page down". Better pick up some more reasonable key or key combination — there are many of them on the keyboard. :-)

—SA
 
Share this answer
 
v2
Comments
[no name] 13-Sep-11 21:02pm    
sorry............but i don't understand who i use this can you understand me this by any example........
sorry............but i don't understand who i use this can you understand me this by any example........
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900