Is there a way to close the column chooser ( ultraGrid1.ShowColumnChooser) using the ESC key or Cancel Key?
Focus has to do with which control on the form has focus. I guess if you click on a child control inside a form, the form itself no longer has focus, since the child control gets the focus.
What you want is Deactivate, not focus.
Well, it seems to me that you could do something similar to the above sample code and just hook the Deactivate event of the form.
I don't think there is any built-in option for this. But I wonder if you could do it by hooking some event of the dialog. I assume you are using the grid's built-in ColumnChooser. You could handle the ultraGrid1_BeforeColumnChooserDisplayed of the grid. This event gives you a reference to the column choser dialog. I tried this out and this seems to work:
private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e) { e.Dialog.KeyPreview = true; e.Dialog.KeyDown += new KeyEventHandler(ColumnChooserDialog_KeyDown); e.Dialog.Closed += new EventHandler(Dialog_Closed); } void ColumnChooserDialog_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { ((Form)sender).Close(); } } void Dialog_Closed(object sender, EventArgs e) { ((Form)sender).KeyDown -= new KeyEventHandler(ColumnChooserDialog_KeyDown); }