Articles in this section
Category / Section

How to create a new column in WinForms GridListControl?

2 mins read

Add a new column


To add a new column into WinForms GridListControl, the QueryColCount event can be used. QueryCellInfo event is used for assigning the cell values for the newly added columns.


C#:

this.gridListControl1.Grid.QueryColCount += Grid_QueryColCount;
this.gridListControl1.Grid.QueryCellInfo += Grid_QueryCellInfo;

private void Grid_QueryColCount(object sender, GridRowColCountEventArgs e)
{
    e.Count = 3;
    e.Handled = true;
}

private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if (e.RowIndex > 0 && e.ColIndex == 3)
    {
        e.Style.CellValue = "testc";
    }
    if (e.RowIndex == 0 && e.ColIndex == 3)
    {
        e.Style.CellValue = "Col name";
    }
}
 VB:
AddHandler Me.gridListControl1.Grid.QueryColCount, AddressOf Grid_QueryColCount
AddHandler Me.gridListControl1.Grid.QueryCellInfo, AddressOf Grid_QueryCellInfo

Private Sub Grid_QueryColCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs)
    e.Count = 3
    e.Handled = True
End Sub

Private Sub Grid_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
    If e.RowIndex > 0 AndAlso e.ColIndex = 3 Then
        e.Style.CellValue = "testc"
    End If
    If e.RowIndex = 0 AndAlso e.ColIndex = 3 Then
        e.Style.CellValue = "Col name"
    End If
End Sub
Adding new column in GridListControl as shown in the below screenshot

Adding new column into WinForms GridListControl


Samples:

C#: Add a new column

VB: Add a new column

 

Conclusion

I hope you enjoyed learning about how to create a new column in GridListControl.

You can refer to our WinForms GridListControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridListControl 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 GridList and other WinForms components.

 

If you have any queries or require clarification, please let us know in the comment section 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)
Please  to leave a comment
Access denied
Access denied