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

adding an object to combobox in grid

hi if you take a combobox cb, cb.Items.Add() function allows one to add an object. I have a combobox embedded on a cell on a grid. Is it possible to add an object to the combobox on the grid. I was able to add a list of strings as follows StringCollection strcol = new StringCollection(); strcol.Add("a"); strcol.Add("b"); this.grid1.ColStyles[2].ChoiceList = strcol; But strcol.Add() doesnt take an object as parameter. So how can we associate an item in combo on the grid to an object?

3 Replies

AD Administrator Syncfusion Team May 25, 2005 07:44 AM

If you want to display something other than strings in a combobox in a grid cell, then you will need to set that cell to use a DataSource, DisplayMember, ValueMember. Take a look at the \Syncfusion\Essential Studio\\Windows\Grid.Windows\Samples\CellTypes\ComboboxCells sample. It uses DataTables for the most part, but you can use any IList object as teh DataSource. One convention is that is you set the ValueMember = null, then grid will actually store the objectt from the IList as teh cell value.

CV Catinat Velmourougan May 26, 2005 03:40 AM

Hi , Consider the following code sample : this.grd.ColStyles[1].BaseStyle = "Heading 1"; this.grd.ColStyles[1].DataSource = this.ColumnSelectView.Items; this.grd.ColStyles[1].DisplayMember = "Text"; I have set the datasource of colstyle to a collection of ListViewItems. I had set the displaymember to text property of the listviewitem. I had set the valuemember to null. But the cell type is combobox. when i select an item on the combobox it displays as shown in image2. I dont want the "ListViewItem:{" to appear in "ListViewItem:{Sedol}".It should be "Sedol". How to do it? image_2_7467.zip

AD Administrator Syncfusion Team May 26, 2005 04:42 AM

Text is a public property for the objects in your list, correct? Case matters. Here is a sample that seems to work as expected in http://www.syncfusion.com/Support/user/uploads/GC_ComboArrayList_71f44b6a.zip Does it work for you? If you cannot spot the problem, can you post a sample that show this problem?

Live Chat Icon For mobile
Up arrow icon