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

Sfdatagrid Combobox

I am trying to add items into a combobox for Sfdatagrid. Currently I have the combobox set up with a datasource but would like to add additional items to the combobox on cellendedit. For instance, I would like to add items into the combobox. I did this the typical datagridview through 

            var comboColumn = datagridview.Columns["Task Description"] as DataGridComboBoxColumn;
                comboColumn.Items.Add(newValue);
            

Any help would be appreciated.

1 Reply

JP Jagadeesan Pichaimuthu Syncfusion Team April 22, 2019 11:30 AM UTC

Hi Julius, 
 
Thanks for using Syncfusion product. 

You can able to add the additional items to the datasource which is bind with ComboBox column in SfDataGrid. Please find the below code snippet here the orderInfo.ShipCityDetails is bind with DataSource of the GridComboBoxColumn, 

this.sfDataGrid1.Columns.Add(new GridComboBoxColumn() { MappingName = "ShipCityID", HeaderText = "Ship City", DisplayMember = "ShipCityName", ValueMember = "ShipCityID", DropDownStyle = DropDownStyle.DropDownList, DataSource = orderInfo.ShipCityDetails }); 


Please find the below screen shot with before adding new item to column, 
 


Now you can add the additional items in button click or any other event like below, 

private void button1_Click(object sender, EventArgs e) 
{             
    orderInfo.ShipCityDetails.Add(new ShipCityDetails() { ShipCityName = "Los Angles", ShipCityID = 137 }); 

Please find the below screen shot which shows the new item is added into the combobox, 

 


Please find the sample for your reference below, 

If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further. 

Regards, 
Jagadeesan

Loader.
Live Chat Icon For mobile
Up arrow icon