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
close icon

Catch value change event of a ComboBox style cell

Hello, everybody.

I need to catch a value change in a ComboBox style cell of a GridGroupingControl, just when it happens, to change that cell's color. Or alternatively, force the row programmatically to commit its changes to the datasource in the CloseUp event of the GridDropDownContainer hosted by the cell, in order to use the RowChanging event of a DataTable.

The problem is that the cell doesn't commit its changes until you leave the row, but I need to change the color immediately, based on the value selected from the ComboBox.

Does anybody know how to do it?

Thank you very much in advance.

1 Reply

HA haneefm Syncfusion Team May 23, 2007 03:53 PM UTC

Hi Jose,

You can handle the TableControlCurrentCellCloseDropDown event of the grid and call the CurrentCell.EndEdit method followed by the Table.EndEdit method to commit the selection changes in a Drop Down. Here is a code snippet.

private void gridGroupingControl1_TableControlCurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlPopupClosedEventArgs e)
{
if( e.Inner.PopupCloseType == Syncfusion.Windows.Forms.PopupCloseType.Done)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
if(cc.Renderer is GridComboBoxCellRenderer)
{
e.TableControl.CurrentCell.EndEdit();
e.TableControl.Table.EndEdit();
}
}
}

If you want to catch the new value in a combobox cell, you need to use Renderer.ControlValue property in a TableControlCurrentCellChanged event. Here is a code snippet.

GridCurrentCell cc = e.TableControl.CurrentCell;
if(cc.Renderer is GridComboBoxCellRenderer)
{
Console.WriteLine("New Value" + cc.Renderer.ControlValue);
Console.WriteLine("New Text" + cc.Renderer.ControlText);

}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon