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 in every cell of a particular column

Hi ,

I've a list of command items.
For eg:

            List<CommandItem> list = new List<CommandItem>();

            list.Add(new CommandItem() { Value = "delete", Name = "Delete" });
            list.Add(new CommandItem() { Value = "remove", Name = "Remove" });
            list.Add(new CommandItem() { Value = "ignore", Name = "Ignore" });
           
I'm dragging and dropping some data into the spreadsheet control. I want all the cells of first column to contain Combo box showing these command items.

I did the same thing in Grid like following
            GridDataColumnStyle columnStyle = new GridDataColumnStyle();
            columnStyle.CellType = "ComboBox";
            columnStyle.ItemsSource = list;
            columnStyle.DropDownStyle = GridDropDownStyle.AutoComplete;
            columnStyle.DisplayMember = "Name";
            columnStyle.ValueMember = "Value";
            GridDataControl gridData = Application.Current.MainWindow.FindName("dataGrid") as GridDataControl;
                  
            DataTable dt =  new DataTable();
            DataColumn dc;
            dc = dt.Columns.Add( "Command");
            gridData.VisibleColumns.Add(new GridDataVisibleColumn() { ColumnStyle = columnStyle, HeaderText = dc.ColumnName, MappingName = dc.ColumnName });

Now I want to do the same thing in SpreadsheetControl where I'm importing data from a datatable. But I'm having trouble in getting the Combo box. How do i set the column style to combo box in spreadsheetControl.
 
Thanks.


1 Reply

KB Kanimozhi Bharathi Syncfusion Team August 26, 2014 12:25 PM UTC

Hi Stephly,

 

Apologize for the delay.

 

We have analysed your query. You can set all the cells of first column to  be Combo box by hooking  QueryCellInfo event in the WorkBookLoaded event  and set the cell type as combo box  like the below code snippet.

 

Code Snippet:

 

 

void grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

 

if (e.Cell.ColumnIndex == 1)

  {

    e.Style.CellType = "ComboBox";

    e.Style.ItemsSource = list;

   }

 

}

 

 

we have also prepared the sample based on your requirement and please find the sample in the below location

 

 

Please let us know if you need any further assistance.

 

Thanks

Kanimozhi B


Attachment: Import_Data_table(1)_7a72b0bb.zip

Loader.
Live Chat Icon For mobile
Up arrow icon