How to disable tab control in window form
-
I have a custom control in a form and I want it to catch the key I press, so I implement the "KeyDown" event, its ok but the event does not fire when I press TAB, Up, Down... (the keys that is used internal to change the tab index of control inside the form). How can I disable it and handle those special keys? Thank you for your help!
-
I have a custom control in a form and I want it to catch the key I press, so I implement the "KeyDown" event, its ok but the event does not fire when I press TAB, Up, Down... (the keys that is used internal to change the tab index of control inside the form). How can I disable it and handle those special keys? Thank you for your help!
-
Hello, When you use te KeyDown event the member 'KeyData' is what you are looking for.
if(e.KeyData == Keys.Tab)
{
e.Handled = true; //prevents that Tab is pressed
}All the best, Martin
But it is not go to the KeyDown method at all when you press Tab, we can not check it.
-
I have a custom control in a form and I want it to catch the key I press, so I implement the "KeyDown" event, its ok but the event does not fire when I press TAB, Up, Down... (the keys that is used internal to change the tab index of control inside the form). How can I disable it and handle those special keys? Thank you for your help!
-
I have a custom control in a form and I want it to catch the key I press, so I implement the "KeyDown" event, its ok but the event does not fire when I press TAB, Up, Down... (the keys that is used internal to change the tab index of control inside the form). How can I disable it and handle those special keys? Thank you for your help!
Hi, AFAIK you should override IsInputKey(). :)
Luc Pattyn [My Articles]
-
Hi, AFAIK you should override IsInputKey(). :)
Luc Pattyn [My Articles]
Hello Luc, I also tried it, because I'm currious, but sadly it doesn't jump in the overriden method. Tried it in the MainForm and in an UserControl.
protected override bool IsInputKey(Keys keyData) { return base.IsInputKey (keyData); //Set my brakepoint here }
I read the msdn infos and know how it should work, but now I'm confused? Any hints? All the best and mercy, Marin -- modified at 11:45 Wednesday 28th February, 2007 Ok, just found out how to use it in an inherit TextBox for example:
protected override bool IsInputKey( System.Windows.Forms.Keys keyData ) { switch ( keyData) { case Keys.Tab: return true; default: return base.IsInputKey(keyData); } }
But it's not working on an UserControl or Form. All the best, Martin
-
Hello Luc, I also tried it, because I'm currious, but sadly it doesn't jump in the overriden method. Tried it in the MainForm and in an UserControl.
protected override bool IsInputKey(Keys keyData) { return base.IsInputKey (keyData); //Set my brakepoint here }
I read the msdn infos and know how it should work, but now I'm confused? Any hints? All the best and mercy, Marin -- modified at 11:45 Wednesday 28th February, 2007 Ok, just found out how to use it in an inherit TextBox for example:
protected override bool IsInputKey( System.Windows.Forms.Keys keyData ) { switch ( keyData) { case Keys.Tab: return true; default: return base.IsInputKey(keyData); } }
But it's not working on an UserControl or Form. All the best, Martin
Hi Martin,
Martin# wrote:
But it's not working on an UserControl or Form.
What do you mean by this ? Is your IsInputKey() not called at all ? (for regular chars, for TAB, arrows...) ? or is its return value simply ignored ? And for which .NET version is this observation ? I am using IsInputKey() on Panels only (both 1.1 and 2.0), no problem there. :)
Luc Pattyn [My Articles]
-
Hi Martin,
Martin# wrote:
But it's not working on an UserControl or Form.
What do you mean by this ? Is your IsInputKey() not called at all ? (for regular chars, for TAB, arrows...) ? or is its return value simply ignored ? And for which .NET version is this observation ? I am using IsInputKey() on Panels only (both 1.1 and 2.0), no problem there. :)
Luc Pattyn [My Articles]
Luc Pattyn wrote:
s your IsInputKey() not called at all ? (for regular chars, for TAB, arrows...) ?
Yes, in all points! -- modified at 14:12 Wednesday February, 2007 I'm just rereading what I was answering before. I think it was not clear. What I meant, was that it is never called! -- modified at 5:09 Thursday 1st March, 2007 I'm only using 1.1
-
Luc Pattyn wrote:
s your IsInputKey() not called at all ? (for regular chars, for TAB, arrows...) ?
Yes, in all points! -- modified at 14:12 Wednesday February, 2007 I'm just rereading what I was answering before. I think it was not clear. What I meant, was that it is never called! -- modified at 5:09 Thursday 1st March, 2007 I'm only using 1.1
I tried it too, I override the IsInputKey method for the FORM, and the method was not called. According to MSDN, it should be called.....