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

combobox

Hi,

I tried using this code, but it doesn't work.


this.gridDataboundGrid.Binder.InternalColumns[1].StyleInfo.CellType = "ComboBox";
this.gridDataboundGrid.Binder.InternalColumns[1].StyleInfo.CellValueType = typeof(string);
this.gridDataboundGrid.Binder.InternalColumns[1].StyleInfo.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;


Please help. Thanks!

4 Replies

JS Jeba S Syncfusion Team September 26, 2007 03:57 AM UTC

Hi coder12345,

Thank you for posting query to us.

You can assign values to the ComboBox using the DataSource. Please refer this code snippets:

this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellType = "ComboBox";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DataSource = dt;
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DisplayMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.ValueMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellValueType = typeof(string);
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;


Please refer the below sample which shows a combo box with Exclusive DropDown.
http://websamples.syncfusion.com/samples/Grid.Windows/F68620/main.htm

Kindly let us know if you need any further assitance.

Thank you for using Syncfusion Products.

Best Regards,
Jeba.


JO John September 26, 2007 07:40 AM UTC

Hi,

I tried the code, but it still doesn't work. Do I need to do it before I do bind to the datagrid or after?

And also, is the DisplayMember and the Valuemember just the mappingname of the column? Thanks!






>Hi coder12345,

Thank you for posting query to us.

You can assign values to the ComboBox using the DataSource. Please refer this code snippets:

this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellType = "ComboBox";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DataSource = dt;
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DisplayMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.ValueMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellValueType = typeof(string);
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;


Please refer the below sample which shows a combo box with Exclusive DropDown.
http://websamples.syncfusion.com/samples/Grid.Windows/F68620/main.htm

Kindly let us know if you need any further assitance.

Thank you for using Syncfusion Products.

Best Regards,
Jeba.


JO John September 26, 2007 07:45 AM UTC

Hi,

I figured out what the problem might be...when I set the datasource to a datatable, it works. But, when I try to set the datasource to a dataview, it doesn't work. Is there a way to get it the combobox to take the items from a dataview? Thanks!





>Hi,

I tried the code, but it still doesn't work. Do I need to do it before I do bind to the datagrid or after?

And also, is the DisplayMember and the Valuemember just the mappingname of the column? Thanks!






>Hi coder12345,

Thank you for posting query to us.

You can assign values to the ComboBox using the DataSource. Please refer this code snippets:

this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellType = "ComboBox";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DataSource = dt;
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DisplayMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.ValueMember = "Col0";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellValueType = typeof(string);
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive;


Please refer the below sample which shows a combo box with Exclusive DropDown.
http://websamples.syncfusion.com/samples/Grid.Windows/F68620/main.htm

Kindly let us know if you need any further assitance.

Thank you for using Syncfusion Products.

Best Regards,
Jeba.


JS Jeba S Syncfusion Team September 26, 2007 11:52 AM UTC

Hi coder12345,

1.Do I need to do it before I do bind to the datagrid or after?
>>>>>>>>>>>>
You should use the code after binding the datagrid.

2.And also, is the DisplayMember and the Valuemember just the mappingname of the column?
>>>>>>>>>>>>

DisplayMember:Sets a string that specifies the mappingname of the column from which to retrieve strings for display in the combo box.

ValueMember:Sets a string that specifies the mappingname of the column from which to get values that correspond to the selections in the drop down list


3.ComboBox with DataView:
>>>>>>>>>>>>>>>>>>>>>>
I am afraid that I was not able to reproduce the dataview issue. I have created a sample to test this issue and it is available in the following link.
http://websamples.syncfusion.com/samples/Grid.Windows/F68620_Modified/main.htm


DataView dv = new DataView();
dv = dt.DefaultView;

this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.CellType = "ComboBox";
this.gridDataBoundGrid1.Binder.InternalColumns[0].StyleInfo.DataSource = dv;


Please have a look at the above sample and if still the issue exists, could you please elaborate the reproduce steps or modify the above sample to show the issue so that we could sort out the cause of the issue and provide you a solution?

Regards,
Jeba.

Loader.
Live Chat Icon For mobile
Up arrow icon