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?
ADAdministrator Syncfusion Team January 27, 2003 04:06 PM
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.