We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do I know, that a ComboBox's drop down list has closed?

I want to know the exact point of time, when the drop down list of a ComboBox has closed, respectively when the user has finished choosing from the list (SelectionChangeComitted). I cannot use the CurrentCellChanged event, because this event is fired each time items from the list are selected with the keyboard's arrow keys. I cannot use the CurrentCellEditingComplete event, because it is fired after leaving the cell. Thanks, Michael

3 Replies

CB Clay Burch Syncfusion Team August 14, 2002 10:30 AM

The GridComboBoxCellRenderer has a DropDownContainer.CloseUp event that you can catch. To hook it, at the bottom of your Form_Load event, get a reference to the combobox cell renderer, and then use that to subscribe to this event.
private void Form1_Load(object sender, System.EventArgs e)
{
	....
	....

	GridComboBoxCellRenderer cbb  = (GridComboBoxCellRenderer) this.gridControl1.CellRenderers["ComboBox"];
	cbb.DropDownContainer.CloseUp += new PopupClosedEventHandler(ComboBoxClosed);
}

private void ComboBoxClosed(object sender, PopupClosedEventArgs e)
{
	Console.WriteLine("ComboBoxClosed");
}


MM Michael Marake August 15, 2002 01:06 AM

Thanks, that seems to work fine. But when would I subscribe to the CloseUp event in a grid that derives from GridControl? The ComboBoxCellRenderer is not yet in the CellRenderers collection during construction of the grid.


CB Clay Burch Syncfusion Team August 15, 2002 02:02 AM

One thing you could do is to subscribe to the grid's Paint event, and hook the CloseUp there, and also unhook the Paint event handler. This way the Paint event handler is only executed once. public class MyGridControl : GridControl { public MyGridControl():base() { this.Paint += new PaintEventHandler(HookDropDown); } private void HookDropDown(object sender, PaintEventArgs pe) { GridComboBoxCellRenderer cbb = (GridComboBoxCellRenderer) this.CellRenderers["ComboBox"]; cbb.DropDownContainer.CloseUp += new PopupClosedEventHandler(ComboBoxClosed); Console.WriteLine("HookDropDown - should see only once"); this.Paint -= new PaintEventHandler(HookDropDown); } private void ComboBoxClosed(object sender, PopupClosedEventArgs e) { Console.WriteLine("ComboBoxClosed"); } }

Loader.
Live Chat Icon For mobile
Up arrow icon