How to select a item in a GridControl combobox

Hi

I have a gridcontrol where one of the cells is defined as a CellType = "ComboBox" and filled with a choicelist. I have no problem with selection of an item by clicking on it.
But how can I programmaticially select a item in the box, and how can I find the selected item?

Thanks

Jerry

4 Replies

HA haneefm Syncfusion Team May 9, 2007 02:45 PM UTC

Hi Jerry,

To set and get the selected item on the combobox cell in a grid , just try the following code

//set
this.gridControl[row,col].CellValue="Text";
//get
Label1.text=this.gridControl[row,col].FormattedText;

Here is a KB Article discuss with the simillar issue.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=233

Thanks for choosing our Syncfusion products.

Best regards,
Haneef


JE Jerry May 10, 2007 08:35 AM UTC

Hi Haneef

And thanks for the answer that helped.
I have a question more. Which event should I use when I want to be notified when the user has changed the value in the ComboBox.

Regards

Jerry


HA haneefm Syncfusion Team May 10, 2007 10:58 PM UTC

Hi Jerry,

To detect combobox cell changes in a grid, you need to handle the CurrentCellChanged event. Here is a code snippet.

//CurrentCellChanged event
[c#]
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if( grid.Model[cc.RowIndex, cc.ColIndex].CellType == "ComboBox" )
{
Console.WriteLine("ComboBox cell changed");
}

Let me know if this helps.

Best regards,
Haneef


JE Jerry May 11, 2007 06:39 AM UTC

Hi Haneef

That worked, so thanks a lot for your help.

Best regards

Jerry

Loader.
Up arrow icon