JS
Jeba S
Syncfusion Team
February 13, 2008 09:17 AM UTC
Hi Sherly,
Thank you for your interest in Syncfusion Products.
Swapping out a cell control while the cell is the active cell is problematic. If it is not the active cell, you could subscribe to the Model.QueryCellInfo event and set e.Style.CellType depending upon whether e.RowIndex was the grid.CurrentCell.RowIndex and if e.ColIndex pointed to the column.
In a GridDataBoundGrid, you cannot set cell specific properties like BackColor, CellType (other than CellValue or Text) using an indexer like this.gridDataBoundGrid[8,10].BackColor=Color.Red. The reason is that in a GridDataBoundGrid, the only data storage is the bound datasource. That only holds a single value. It does not hold TextColor, or Backcolor, or any of the other many cell specific properties. So, in order to set cell specific properties in a GridDataBoundGrid, you must catch the PrepareViewStyleInfo event (or Model.QueryCellInfo event). In your handler, you check e.RowIndex and e.ColIndex, and if these point to the cell you want to change, you set e.Style to the value you want.
this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if (e.RowIndex > 0 && e.ColIndex > && e.ColIndex==1 && e.RowIndex==2)
{
e.Style.CellType = GridCellTypeName.ComboBox;
e.Style.ChoiceList=choiceList;
}
}
Kindly let us know if you need any further assistance.
Regards,
Jeba.