Binding values to Combo Box cell type during runtime.

Hi I am using Gridcontrol and while initializing the column I am setting a particular column''s celltype as "ComboBox". I want to bind some data to that coulumn during runtime.(to display all countrycodes), How to set the datasource? Thanks Ravi

3 Replies

AD Administrator Syncfusion Team April 19, 2006 07:00 AM UTC

Hi Ravi, Please try this code to assign the datsource of the combobox cell in a grid during runtime. //For comboboxcell type column 2 this.gridControl1[1,2].DataSource = GetTable(cc.Renderer.ControlText); this.gridControl1[1,2].DisplayMember = "Name"; this.gridControl1[1,2].ValueMember = "Value"; Here is a sample for implementing it. http://www.syncfusion.com/Support/user/uploads/ComboSample_1178bc36.zip Please let me know if you need any further assistance. Regards, Haneef


RA Ravichandran April 24, 2006 01:57 PM UTC

Hi We are having our own datasoruce ( its an array of objects). In QueryCellInfo event we are setting the values for each cell during runtime by assigning the values from our datasoruce.. if (e.RowIndex > 0) { e.Style.CellValue = m_document[e.RowIndex - 1, e.ColIndex]; e.Handled = true; } where m_document is collection of objects. Now here in one of the col I want to have combobox. I dont knwo how to bind the combo with another datasource ( array of country objects) .. Pls reply me AEAP. Thaks Ravi >Hi Ravi, > >Please try this code to assign the datsource of the combobox cell in a grid during runtime. > >//For comboboxcell type column 2 >this.gridControl1[1,2].DataSource = GetTable(cc.Renderer.ControlText); >this.gridControl1[1,2].DisplayMember = "Name"; >this.gridControl1[1,2].ValueMember = "Value"; > >Here is a sample for implementing it. >http://www.syncfusion.com/Support/user/uploads/ComboSample_1178bc36.zip > >Please let me know if you need any further assistance. >Regards, >Haneef


AD Administrator Syncfusion Team April 25, 2006 04:54 AM UTC

Hi Ravi, Could you try this code to configure the combobox celltype.Here is a sample. if(e.ColIndex == 2 && e.RowIndex > 0) { // For more than on element in a arraylist e.Style.DisplayMember/ValueMember is necessary for showing the element. e.Style.DataSource = GetList(m_document[e.RowIndex - 1, e.ColIndex].ToString()); e.Style.CellType = "ComboBox"; } Here is a sample. http://www.syncfusion.com/Support/user/uploads/ComboSample_1b508fa6.zip Please let me know if this helps. Regards, Haneef

Loader.
Up arrow icon