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 old and new value of 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.
C#
//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()); }
VB
'Hook the Event in Form_Load Me.gridControl1.CurrentCellCloseDropDown += 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 Sub
The following screenshot illustrates the output.
Figure 1: Displaying the old value of the ComboBox cell.
Samples:
C#: ComboBoxOldValue
VB:
ComboBoxOldValue