)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the new and old values when an item is selected in a combobox cell in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 19, 2019

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.

Displaying the old value of the combobox cell

Figure 1: Displaying the old value of the ComboBox cell.

Samples:

C#: ComboBoxOldValue

VB:

ComboBoxOldValue

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon