P
Peter B
Hi!
I am using the keydown event on my form controls to execute certain
operations (the handheld device I am using has a full alphanumeric
keyboard). For instance Ctrl + S saves the current object. This happens
whatever control is focused on the form, so I have added keydown
eventhandler on all controls that can be focused.
The problem I have is that when a list based control such as the combobox is
focused, and the user types Ctrl + "a letter", let's say 'S', the object is
first saved, BUT then the control looks for any objects in it's list that
starts with the typed letter ('S'), and selects it (if found). This means
the next item starting with 'S' is selected, which ofcourse is
unacceptable, I need to prevent the event to continue after I process it.
From my research I have found that the easy solution would be to set the
KeyEventArgs Handled property to true. But I don't get this to work. Infact,
the Handled property doesn't seem to be usefull at all?
code snippet:
case Keys.S:
if( e.Control )
{
e.Handled = true;
this.Save();
}
break;
I was hoping this would stop the low level keydown event, but it doesn't...
Note that this is only a problem in list based controls (ComboBox and
ListView are the two controls I have tried). TextBox will not write out an
'S' if Ctrl + S is pressed.
What can I do here? Could anyone shed some light please
regards,
Peter
I am using the keydown event on my form controls to execute certain
operations (the handheld device I am using has a full alphanumeric
keyboard). For instance Ctrl + S saves the current object. This happens
whatever control is focused on the form, so I have added keydown
eventhandler on all controls that can be focused.
The problem I have is that when a list based control such as the combobox is
focused, and the user types Ctrl + "a letter", let's say 'S', the object is
first saved, BUT then the control looks for any objects in it's list that
starts with the typed letter ('S'), and selects it (if found). This means
the next item starting with 'S' is selected, which ofcourse is
unacceptable, I need to prevent the event to continue after I process it.
From my research I have found that the easy solution would be to set the
KeyEventArgs Handled property to true. But I don't get this to work. Infact,
the Handled property doesn't seem to be usefull at all?
code snippet:
case Keys.S:
if( e.Control )
{
e.Handled = true;
this.Save();
}
break;
I was hoping this would stop the low level keydown event, but it doesn't...
Note that this is only a problem in list based controls (ComboBox and
ListView are the two controls I have tried). TextBox will not write out an
'S' if Ctrl + S is pressed.
What can I do here? Could anyone shed some light please
regards,
Peter