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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I change the DataSource of one ComboBox cell depending upon the value selected in another ComboBox cell in a GridDataBoundGrid?

Platform: WinForms |
Control: GridDataBoundGrid(Classic)


The DataSource for a specific cell can be changed dynamically by handling the Model.QueryCellInfo event. Querying the style info of a cell using grid[rowindex, colindex].text in the QueryCellInfo will fire the event again and will lead to a recursive call. You should adopt a logic not to Querycellinfo inside this event.

One way of acheving this would be to set a flag in the ClosedCellDropDown when a particular value is selected and assign the datasource only when the flag is set. In the attached sample choose the value "One" in cell 2,2 to change the DataSource for a ComboBox in the Cell 3,3.


private void gridModel_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)


if(e.ColIndex == 3 && e.RowIndex == 3)


e.Style.CellType = "ComboBox";

e.Style.ChoiceList = null;


if(e.ColIndex == 3 && e.RowIndex == 3 && flag)


StringCollection items = new StringCollection();






e.Style.ChoiceList = items;



private bool flag = false;

private void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender,

Syncfusion.Windows.Forms.PopupClosedEventArgs e)


GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;

if(cc.ColIndex == 2 && cc.RowIndex == 2)


flag = false;

GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;

if (cr.ControlText == "One")


flag = true;



flag = false;




Private Function GetTable() As DataTable

Dim dt As DataTable = New DataTable("MyTable")

Dim nCols As Integer = 4

Dim nRows As Integer = 10

Dim i As Integer = 0

Do While i < nCols

dt.Columns.Add(New DataColumn(String.Format("Col{0}", i)))

i += 1


i = 0

Do While i < nRows

Dim dr As DataRow = dt.NewRow()

Dim j As Integer = 0

Do While j < nCols

dr(j) = String.Format("row{0} col{1}", i, j)

j += 1



i += 1


Return dt

End Function

Private flag As Boolean = False

Private Sub gridDataBoundGrid1_CurrentCellCloseDropDown(ByVal sender As Object, ByVal e As

Syncfusion.Windows.Forms.PopupClosedEventArgs) Handles gridDataBoundGrid1.CurrentCellCloseDropDown

Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell

If cc.ColIndex = 2 AndAlso cc.RowIndex = 2 Then

flag = False

Dim cr As GridComboBoxCellRenderer = CType(IIf(TypeOf cc.Renderer Is GridComboBoxCellRenderer, cc.Renderer,

Nothing), GridComboBoxCellRenderer)

If cr.ControlText = "One" Then

flag = True


flag = False

End If

End If

End Sub

Here is the link with both CS and VB samples: http://help.syncfusion.com/support/samples/kb/grid.windows/GDBGCombo/Combo.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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