You need to set the
KeyPreview
property of Form to true. This will make all the keys come to the Form before reaching any of the child controls. In addition to that, you will have to handle
KeyUp
,
KeyDown
messages for your main Form as well and in the handling of those, you will have to mark those as
Handled
if your Combobox is in focus.
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (comboBox1.Focused)
e.Handled = true;
}
Here is a link from MSDN which explains this
KeyPreview
property in detail with examples:
Link here[
^]