To expand or collapse all grouped rows at once, you can use the ExpandGroupRow and CollapseGroupRow methods. In this topic you'll add buttons to your form that will expand and collapse your grouped grid using the ExpandGroupRow and CollapseGroupRow methods.
Complete the following steps:
In the Designer
In the Properties window set the following properties:
In Code
Add the following code to the Form_Load event:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.Button1.Text = "Expand" Me.Button2.Text = "Collapse" |
To write code in C#
C# |
Copy Code
|
---|---|
this.button1.Text = "Expand"; this.button2.Text = "Collapse"; |
Visual Studio adds the following code to the Form_Load event:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.ProductsTableAdapter.Fill(Me.Products._Products) |
To write code in C#
C# |
Copy Code
|
---|---|
this.productsTableAdapter.Fill(this.products._Products); |
In the Designer
In the C1TrueDBGrid Tasks menu, select GroupBy from the Data Layout drop-down.
In Code
Add the following code to the Form_Load event:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.C1TrueDBGrid1.ExpandGroupRow(-1, True) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.C1TrueDBGrid1.CollapseGroupRow(-1) End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void button1_Click(object sender, EventArgs e) { this.c1TrueDBGrid1.ExpandGroupRow(-1, true); } private void button2_Click(object sender, EventArgs e) { this.c1TrueDBGrid1.CollapseGroupRow(-1); } |