Browse by Tags
All Tags » Keyboard and Mouse Handling » Custom Controls (RSS)
Sorry, but there are no more tags available to filter with.
-
|
By default, the arrow keys are not handled by a control's key processing code, but instead are filtered out for focus management. Hence, the control's KeyDown, KeyUp and KeyPressed events are not raised when you press an arrow key. If you want...
|
-
|
You can handle the control's KeyPress event and indicate the key has been handled. Below is code that prevents a TextBox from getting an 'A' and the Enter key. private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs...
|
-
|
If the Control.ModifierKeys doesn't address your issue, then use P/Invoke and call GetKeyState directly. Declare this class first: [ ComVisibleAttribute( false ), SuppressUnmanagedCodeSecurityAttribute() ] internal class NativeMethods { [ DllImport...
|
-
|
Use the static property Control.ModifierKeys. Console.WriteLine(Control.ModifierKeys); if ( (Control.ModifierKeys & Keys.Shift) != 0 ) Console.WriteLine("the shift key is down"); if ( (Control.ModifierKeys & Keys.Alt) != 0 ) Console...
|
-
|
This can be done through the SendKeys class in the System.Windows.Forms namespace. Contributed from George Shepherd's Windows Forms FAQ
|