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

Select values in a ComboBox in a GridControl in a WinForm

I have a cell of the ComboBox type which uses a datasource and display/value-members. I would like to pre-select specific values in the combo before displaying it to the user. So if the combox contains the values 1, 5, 10 and 20 I would like 10 to be displayed in the combo when the user opens the form. This would be somewhat similar to use SetSelectedIndex = 2 in a standard Windows combobox. Thanks in advance.

3 Replies

AD Administrator Syncfusion Team November 11, 2005 10:19 AM UTC

Try setting the CellValue to be the value member of the entry you want to see. So if the display member has a value of "Apple", and its corresponding valuememer is 192, then try setting: grid[rowIndex, colIndex].CellValue = 192;


GA Geir Aamodt November 11, 2005 01:39 PM UTC

That works perfectly, thanks a lot Clay. Another ComboBox follow up; is it possible to have text in the combo that is not part of the datasource. Like when you open the form and in the combo you find the text "Please select Color" (or something like that.


AD Administrator Syncfusion Team November 11, 2005 02:19 PM UTC

There are no property setting for this. You would have to code it. One way to try to do this would be to use a GridListControl celltype and show the column headers in the GridListControl. You could make the first header in the GridListControl a covered cell and put your text there. But it would likely require handling events on the embedded grid within the gridlistcontrol to get this working.

Loader.
Live Chat Icon For mobile
Up arrow icon