2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Setting row and column countYou can change the Grid’s RowCount and ColCount properties by using the designer. Set these properties after calling InitializeComponent in the form’s constructor or anytime later in your code using the following code example. Using direct properties C# // set RowCount for GridControl gridControl1.RowCount = 20; // set ColCount for GridControl gridControl1.ColCount = 120; VB ' set RowCount for GridControl gridControl1.RowCount = 20 ' set ColCount for GridControl gridControl1.ColCount = 120 Using Events The events QueryRowCount and QueryColCount are used to set the count for rows and columns. C# //Hook these events to set the RowCol count gridControl1.QueryColCount += gridControl1_QueryColCount; gridControl1.QueryRowCount += gridControl1_QueryRowCount; void gridControl1_QueryColCount(object sender, GridRowColCountEventArgs e) { //Set ColCount for GridControl e.Count = int.Parse(colCountText.Text); e.Handled = true; } void gridControl1_QueryRowCount(object sender, GridRowColCountEventArgs e) { //Set RowCount for GridControl e.Count = int.Parse(rowCountTxt.Text); e.Handled = true; } VB //Hook these events to set the RowCol count gridControl1.QueryColCount += gridControl1_QueryColCount; gridControl1.QueryRowCount += gridControl1_QueryRowCount; Private Sub gridControl1_QueryColCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs) 'Set ColCount for GridControl e.Count = Integer.Parse(colCountText.Text) e.Handled = True End Sub Private Sub gridControl1_QueryRowCount(ByVal sender As Object, ByVal e As GridRowColCountEventArgs) 'Set RowCount for GridControl e.Count = Integer.Parse(rowCountTxt.Text) e.Handled = True End Sub The following screenshot illustrates the output. Figure 1: Setting the row, col count using QueryRowCount, QueryColCount events Samples: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.