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

GridDataBoundGrid ComboBox List Binding

Thread ID:





2521 Jan 27,2003 06:04 PM UTC Jan 27,2003 09:06 PM UTC WinForms 1
Tags: GridControl
Kenneth Johnson
Asked On January 27, 2003 06:04 PM UTC

I am binding the combobox lists for an entire column as follows: this.GridBoundColumns[iColIndex].StyleInfo.DataSource = oListTable; this.GridBoundColumns[iColIndex].StyleInfo.DisplayMember = "DisplayColumn"; this.GridBoundColumns[iColIndex].StyleInfo.ValueMember = "ValueColumn"; This works fine. Then, depending on user input, I need to rebind the combobox list of a single cell and am trying to use this code: GridStyleInfo oCurrCell = this[iRowIndex, iColIndex]; if (null != oCurrCell) { oCurrCell.DataSource = oListTable; oCurrCell.DisplayMember = "DisplayColumn"; oCurrCell.ValueMember = "ValueColumn"; } This doesn't have any affect. What do I need to do to change the data binding of the combobox list for the current cell?

Administrator [Syncfusion]
Replied On January 27, 2003 09:06 PM UTC

In a GridDataBoundGrid, there is no grid data object to store individual cell properties. So, you cannot use code like grid[row, col].DataSource = xyz. The reason is that there is no place to store this individual cell data. (The only thing you can do by indexing a grid cell is to set the Text or CellValue property as this property is mapped back to the DataSource bound to the GridDataBoundGrid.) To change individual cell style attributes, you can use either the GridDataBoundGrid.PrepareViewStyleInfo event, or the GridDataBoundGrid.Model.QueryCellInfo event. The PrepareViewStyleInfo is generally used for style propeties that affect the appearance of the cell (such as the BackColor or Font). QueryCellInfo is used to handle properties that may be used by other aspects of the grid. To change the DataSource, DisplayMember and ValueMember, I would first try QueryCellInfo. Here is some code that sets the displaymember in col 4 based on the cell value in col 2.
private void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
	if(e.RowIndex > 0 && e.ColIndex == 4)
		e.Style.CellType = "ComboBox";
		e.Style.DataSource = this.foreignKeys;
		e.Style.DisplayMember = this.gridDataBoundGrid1[e.RowIndex, 2].Text;
		e.Style.ValueMember = "WordID";
		e.Handled = true;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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