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

Programatically Setting SelectedIndex of ComboBox in GDBG

Is there a way to programatically change the SelectedIndex of a ComboBox in a GridDataBoundGrid? I need to do this to reflect data returned from the database. I am using beta version 2.0.2.1. Thanks, Chris

3 Replies

AD Administrator Syncfusion Team March 3, 2004 12:23 PM UTC

The grid really does not track ''the selected index''. The only thing its knows is the cell value. The selected index is only around when the dropdown is visible (and just before and just after). Here is a kb link showing how you can get at the selected index as the combobox closes. http://www.syncfusion.com/Support/article.aspx?id=10421 You can use similar code in CurrentCellShowingDropDown or CurrentCellShowedDropDown to get at the selected index. But when there is no combobox dropped or about to be dropped or closed, then there is no ''selected index'' available.


CR Chris R March 5, 2004 01:27 PM UTC

So how do I programatically set the values of those combobox cells from the info I get from the database?


AD Administrator Syncfusion Team March 5, 2004 02:23 PM UTC

In a GridDataBoundGrid, you do not have to do anything to get the cell values to reflects the values from teh database other than setting the DataSource on the grid. Then the column in the grid where the comboboxes are should have whatever values were in the column from the grid''s DataSource. Are you setting gridboundcolumn.StyleInfo.DataMember and gridboundcolumn.StyleInfo.ValueMember for this combobox column? If so, and you later want to set a value programatically to this column, then you should set the Text property of the style to some appropriate ValueMember value, ie. this.grid[row,col].Text = somethingFromTheValueMembers; in the columns DataSource. If that does not help, can you explain exactly what you need to do?

Loader.
Live Chat Icon For mobile
Up arrow icon