)
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 a column width in WinForms GridListControl?

Platform: WinForms |
Control: GridListControl |
Published Date: March 15, 2017 |
Last Revised Date: January 2, 2020
Tags: columnwidth

Column width

To set the width of a GridListControl’s particular column, ColWidths property or QueryColWidth event can be used.

Using ColWidths property

C#

//To change the width of the columns.
this.gridListControl1.Grid.Model.ColWidths["CategoryName"] = 125;
this.gridListControl1.Grid.Model.ColWidths["Description"] = 125;

VB

'To change the width of the columns.
Me.gridListControl1.Grid.Model.ColWidths("CategoryName") = 125
Me.gridListControl1.Grid.Model.ColWidths("Description") = 125

 

Using QueryColWidth event

The column width can be set by setting the Size property. The e.Handled property should be set to true.

C#

//Event subscriptions.
this.gridListControl1.Grid.QueryColWidth += Grid_QueryColWidth;
 
//Event Customization
private void Grid_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
    if (e.Index == 1 || e.Index == 2)
    {
        e.Size = 125;
        e.Handled = true;
    }
}

 

VB

'Event subscriptions.
AddHandler Me.gridListControl1.Grid.QueryColWidth, AddressOf Grid_QueryColWidth
'Event Customization
Private Sub Grid_QueryColWidth(ByVal sender As Object, ByVal e As GridRowColSizeEventArgs)
    If e.Index = 1 OrElse e.Index = 2 Then
        e.Size = 125
        e.Handled = True
    End If
End Sub

 

Screenshot

Set the column width in GridListControl

Samples:

C#: Column_Width_CS 

VB: Column_Width_VB

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