Articles in this section

How to set the properties of the embedded Grid in the GridListControl CellType in WinForms GridControl?

Embedded grid in GridListControl cell type


To set the properties of the embedded Grid in the GridListControl CellType, you need to handle the CurrentCellShowingDropDown event. In the CurrentCellShowingDropDown event, cast the current cell’s renderer as GridDropDownGridListControlCellRenderer. By using the list control, set the embedded Grid properties. You can also set the number of rows that are to be visible in the drop-down.

 

Refer to the following code examples.

//Hooks the CurrentCellShowingDropDown event in Form_Load()
this.gridControl1.CurrentCellShowingDropDown += gridControl1_CurrentCellShowingDropDown;

void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
    GridControlBase grid = sender as GridControlBase;
    GridCurrentCell cc = grid.CurrentCell;

    //Condition for checking the renderer whether it's a GridDropDownGridListControlCellRenderer.
    if (cc.Renderer is GridDropDownGridListControlCellRenderer)
    {
        GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;

        //Sets the number of dropdown rows 
        ((GridDropDownGridListControlPart)cr.ListControlPart).DropDownRows = 4;

        // Adjust the properties in the Embedded Grid
        cr.ListControlPart.Grid.ColWidths[1] = 30;

        // hides the row one and two from the drop down
        cr.ListControlPart.Grid.SetRowHidden(5, 6, true);

        // sets the background color for the list drop down
        cr.ListControlPart.BackColor = Color.Orange;
    }
}
'Hooks the CurrentCellShowingDropDown event in Form_Load()
AddHandler Me.gridControl1.CurrentCellShowingDropDown, AddressOf gridControl1_CurrentCellShowingDropDown

Private Sub gridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
     Dim grid As GridControlBase = TryCast(sender, GridControlBase)
     Dim cc As GridCurrentCell = grid.CurrentCell

     'Condition for checking the renderer whether it's a GridDropDownGridListControlCellRenderer.
     If TypeOf cc.Renderer Is GridDropDownGridListControlCellRenderer Then
           Dim cr As GridDropDownGridListControlCellRenderer = TryCast(cc.Renderer, GridDropDownGridListControlCellRenderer)

           'Sets the number of dropdown rows 
           CType(cr.ListControlPart, GridDropDownGridListControlPart).DropDownRows = 4

           ' Adjust the properties in the Embedded Grid
           cr.ListControlPart.Grid.ColWidths(1) = 30

           ' hides the row one and two from the drop down
           cr.ListControlPart.Grid.SetRowHidden(5, 6, True)

           ' sets the background color for the list drop down
           cr.ListControlPart.BackColor = Color.Orange
     End If
End Sub

The screenshot below illustrates the GridListControl cell in the GridControl.

 

GridListControl cell in a grid control

Figure 1: GridListControl cell in a grid control

 

Samples:

C#: GridListControlCellType

VB: GridListControlCellType

 

Conclusion

I hope you enjoyed learning about how to set the properties of the embedded Grid in the GridListControl CellType in WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.


For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied