Articles in this section
Category / Section

How to set the column width of the WinForms GridGroupingControl?

1 min read

Column width

The column width for the WinForms Grid Grouping control can be set by using the TableDescriptor.Columns[“index”].Width property. The column width can also be set by using the TablModel.QueryColWidth() event handler.

By using the GridColumnDescriptor:

In the given code example, the column width is set for the second column.

C#

//Sets the column width by using the Columns.Width property of the TableDescriptor.
this.gridGroupingControl1.TableDescriptor.Columns[1].Width = 200;

VB

'Sets the column width by using the Columns.Width property of the TableDescriptor.
Me.gridGroupingControl1.TableDescriptor.Columns(1).Width = 200

By using the QueryColWidth Event:

In the following event handler, the column width of the Grid Grouping control is set for the third column.

C#

//Hooks the event in the Form_Load to set the colwidth for the Grid.
this.gridGroupingControl1.TableModel.QueryColWidth += TableModel_QueryColWidth;
void TableModel_QueryColWidth(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
{
   if (e.Index ==3)
   {
      //Sets the column width.
      e.Size = 200;
      e.Handled = true;
   }
}

VB

'Hooks the event in the Form_Load to set the colwidth for the Grid.
Private Me.gridGroupingControl1.TableModel.QueryColWidth += AddressOf TableModel_QueryColWidth
Private Sub TableModel_QueryColWidth(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs)
   If e.Index =3 Then
      'Sets the column width.
      e.Size = 200
      e.Handled = True
   End If
End Sub

The following screenshot displays the column width set for the Grid Grouping control.

Set the column width for GridGroupingControl

Note:

In the GridColumnDescriptor, it takes the column in a zero based index whereas in the QueryColWidth event, ‘e.Index’ takes the column index from one.

Samples:

C#: SetColWidthGGC

VB: SetColWidthGGC

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