Chsnging Choicelist for a specific cell in GridDataBoundGrid

Hello,

I am using a GridDataBoundGrid, wherein in CellsChanged event i need to edit the choicelist of a specific cell whose celltype is ComboBox.But GridDataBoundGrid.Model[rowIndex, colIndex].ChoiceList = stringCollectionInstance;

does not seem to work can u suggest how i should go about doing this?


1 Reply

AD Administrator Syncfusion Team March 17, 2008 01:22 PM UTC


Hi keshav,

Thanks for the interest in Syncfusion products.

You can edit the combobox choicelist of a specific cell by handling PrepareViewStyleInfo event. Please refer the code snippet below :


private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex == 1 && e.ColIndex == 1)
{
e.Style.CellType = "ComboBox";
e.Style.BackColor = Color.Red ;
e.Style.ChoiceList = item2;
}
}


You can set your choicelist in your CurrentCellChanged as follows:


StringCollection item2;
void gridDataBoundGrid1_CurrentCellChanged(object sender, EventArgs e)
{
item2 = new StringCollection();
item2.Add("aaaaaaaa");
item2.Add("bbbbbbb");
item2.Add("cccccccc");
item2.Add("Sddddddd");
}


Please refer the sample in the below link that illustrate the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F72329/main.htm

Please let me know if this is not what you needed.

Regards,
Asem.


Loader.
Up arrow icon