)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 18, 2019
Tags: celltype

Embedded grid in GridListControl celltype

To set the properties of the embedded Grid in the GridListControl CellType, you need to handle the CurrentCellShowingDropDown event. In 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.

C#

//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;
    }
}

 

VB

'Hooks the CurrentCellShowingDropDown event in Form_Load()
Me.gridControl1.CurrentCellShowingDropDown += 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

 

GridListControl cell in a grid control

Figure 1: GridListControl cell in a grid control

 

Samples:

C#: GridListControlCellType

VB: GridListControlCellType

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon