Category / Section
How to get the new and old values when an item is selected in a combobox cell in WinForms GridControl?
1 min read
Shows the old and new values of the combobox
The CurrentCellCloseDropDown event gets triggered when a dropdown is closed in a Grid cell. You can obtain the new value of the ComboBox by using CurrentCell's Renderer property and the old value from the Grid.
//Hook the Event in Form_Load
this.gridControl1.CurrentCellCloseDropDown += gridControl1_CurrentCellCloseDropDown;
void gridControl1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
cc = this.gridControl1.CurrentCell;
// show the new value in the ComboBox selected item
MessageBox.Show("New Value is " + cc.Renderer.GetCellValue().ToString());
// Show the old value in the ComboBox selected item
MessageBox.Show("Old Value is " + this.gridControl1[cc.RowIndex, cc.ColIndex].CellValue.ToString());
}'Hook the Event in Form_Load
AddHandler Me.gridControl1.CurrentCellCloseDropDown, AddressOf gridControl1_CurrentCellCloseDropDown
Private Sub gridControl1_CurrentCellCloseDropDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.PopupClosedEventArgs)
cc = Me.gridControl1.CurrentCell
' show the new value in the ComboBox selected item
MessageBox.Show("New Value is " & cc.Renderer.GetCellValue().ToString())
' Show the old value in the ComboBox selected item
MessageBox.Show("Old Value is " & Me.gridControl1(cc.RowIndex, cc.ColIndex).CellValue.ToString())
End SubThe following
screenshot illustrates the output.

Figure 1: Displaying the old value of the ComboBox cell.
Samples:
C#: ComboBoxOldValue
VB: ComboBoxOldValue