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.
Unfortunately, activation email could not send to your email. Please try again.

ComboBox in every cell of a particular column

Thread ID:

Created:

Updated:

Platform:

Replies:

117122 Aug 18,2014 03:05 AM Aug 26,2014 08:25 AM WPF 1
loading
Tags: SpreadsheetControl(Classic)
stephly
Asked On August 18, 2014 03:05 AM

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.


Kanimozhi Bharathi [Syncfusion]
Replied On August 26, 2014 08:25 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;