Articles in this section

How to set the column width of the WinForms GridGroupingControl?

Column width


The column width for the WinForms GridGroupingControl 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 GridGroupingControl 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 column width for the Grid
AddHandler Me.gridGroupingControl1.TableModel.QueryColWidth, AddressOf TableModel_QueryColWidth

Private Sub TableModel_QueryColWidth(sender As Object, 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 GridGroupingControl.

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

 

Conclusion

I hope you enjoyed learning about how to set the column width of the WinForms GridGroupingControl.

You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.

 

For current customers, you can check out our WinForms 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 WinForms GridGroupingControl and other WinForms components.

 

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-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