Articles in this section
Category / Section

How to hide a range of rows and columns in WinForms GridGroupingControl?

2 mins read

Hide a range of rows or columns

You can hide a range of rows/columns in GridGroupingControl by using the RowHiddenEntries property or the ColHiddenEntries property. You have to pass the GridRowHidden or GridColHidden collection in the AddRange() method. GridRowHidden or GridColHidden contains the collection rows/columns that are to be hidden.

C#

// to hide range of rows
private void buttonAdv1_Click(object sender, EventArgs e)
{
   // range of rows to hide
   int n = 3;
   // the count will be taken from caption and header rows (n +2)
   GridRowHidden[] hiddenrows = new GridRowHidden[n + 2];
   for(int i = 0; i < n + 2; i++)
   {
      hiddenrows[i] = new GridRowHidden(i + 1);
   }
   this.gridGroupingControl1.TableControl.Model.RowHiddenEntries.AddRange(hiddenrows);
}
// to hide range of columns
private void button1_Click(object sender, EventArgs e)
{
   // range of column to hide
   int n = 3;
   GridColHidden[] hiddenCols = new GridColHidden[n];
   for(int i = 0; i < n ; i++)
   {
      hiddenCols[i] = new GridColHidden(i + 1);
   }
   this.gridGroupingControl1.TableControl.Model.ColHiddenEntries.AddRange(hiddenCols);
}

VB

’ to hide range of rows
Private Sub buttonAdv1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonAdv1.Click
   ' range of rows to hide
   Dim n As Integer = 3
   ' the count will be taken from caption and header rows (n +2)
   Dim hiddenrows(n + 2 - 1) As GridRowHidden
   For i As Integer = 0 To n + 2 - 1
       hiddenrows(i) = New GridRowHidden(i + 1)
   Next i
   Me.gridGroupingControl1.TableControl.Model.RowHiddenEntries.AddRange(hiddenrows)
End Sub
’ to hide range of columns
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
   ' range of column to hide
   Dim n As Integer = 3
   Dim hiddenCols(n - 1) As GridColHidden
   For i As Integer = 0 To n - 1
      hiddenCols(i) = New GridColHidden(i + 1)
   Next i
   Me.gridGroupingControl1.TableControl.Model.ColHiddenEntries.AddRange(hiddenCols)
End Sub

Samples:

C#: GGC_hide_rows_and_columns_C#.zip

VB: GGC_hide_rows_and_columns_VB.zip

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