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
close icon

Celltype for specific column with specific rowindex in griddataboundgrid

i'm using vs2003, i'm trying to set celltype of a specific column
i'm using this code :"grid1.Binder.InternalColumns[colIndex].StyleInfo.CellType="ComboBox";"
on CurrentCellChanged event

it has changed.
but i just want to change celltype of column on row which selected by user.

please advice

sherly





1 Reply

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.


Loader.
Live Chat Icon For mobile
Up arrow icon