Search code examples
winformscomboboxsyncfusiongridgroupingcontrol

Setting row specific content for a Combobox in a GridGroupingControl cell


In my WinForms application, I have a GridGroupingControl where I need to display a certain data collection that has a rather complex structure. The basic idea is that I want to have a combobox in one cell on each row, and that combobox has to contain a list that is defined for each row in the data collection.

Now my question is: How do I bind that specific list to the combobox in question?

My guess here is that I need to define this binding not on the column schema, but on the row schema in some way. How do I do this? I had guessed that I would add event handlers of the type "control.Row.DataBound" but I have not found any of the sort in this control.

NB: I come from a web development background, so my knowledge of Winforms is rather limited to begin with. Please bear that in mind when answering.


Solution

  • To insert a combo box in grid, you need to set the celltype as ComboBox and the data for combobox using ChoiceList. Please refer the below provided code snippet and KB’s for further clarification. The below code can be directly used in Form load or Constructor. If you want to set a specific cell as combobox cell then you need to set the cell type of that particular cell in QueryCellStyleInfo event (refer the kb’s for this).

    Code Snippet:

    this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.CellType= GridCellTypeName.ComboBox;
    this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.ChoiceList = list1;
    this.gridGroupingControl1.TableDescriptor.Columns[1].Appearance.AnyRecordFieldCell.CellValue = "Trial1";
    

    KB links: