I want to do this. I have 4 buttons in my form, such as arrow keys when I pressed the left button, I want to do what the real left arrow keys like I want to do all 4 buttons. I searched and found only about KeyEven function, I Self-learning any help would be appreciated.
Thanks
From an MSDN article:
< P> Some key presses, such as tabs, returns, ESCs and arrow keys, generally ignore some controls because they are not considered to be an input key press. For example, by default, one button ignores control arrow keys, due to pressing the arrow key, there is usually a focus to move in the previous or next control. Arrow keys are considered as navigation keys and by pressing these keys, the keydown event is usually not increased for one button. However, increasing the preview kindred event by pressing the arrow keys for a button. By handling the PreviewKeyDown event for one button and setting the IsInputKey property to the right, you can increase the key attack event when you press the arrow keys. However, if you control the arrow keys, the focus will no longer be in the previous or next control.I'm referring to the code I received there. I have not tested it.
Public form 1 () {InitializeComponent (); // Form that has a button on it button 1 PreviewedDown + = New PreviewCodeDownAventHandler (Button1_PreviewKeyDown); Button 1 Kadoun + = New KeyWeek Handler (Button 1_KedDown); Button 1 ContentsManuum Strip = New Context Menustrip (); // Click context menu to button 1. CONTACT MANUITY STRIKE. Add ("One"); Button1.ContextMenuStrip.Items.Add ("Two"); Button1.ContextMenuStrip.Items.Add ("Three"); } // By default, the KeyDown ARROW key is to fire for Zero Button 1_KeyDown (Object Sender, KeyEventArgs E) {Switch (e.KeyCode) {Case Keys.Down: Case Keys.Up: if (button1.ContextMenuStrip! = Null) Not {Button1.ContextMenuStrip.Show (button1, new point (0, button 1.high), toolstrip dopdowndirectory.Balorite); } break; }} // previewKeyDown is where you preview the key. // Do not put any logic here, instead of setting IsInputKey to the right, use the // KeyDown event. Private Zero Button 1_PreviewKeyDown (Object Sender, PreviewKeyDownEventArgs E) {Switch (e.KeyCode) {Case key.Down: Case Keys.Up: e.IsInputKey = true; break; }}
this is the link
Hope it helps you, good luck.
No comments:
Post a Comment