Articles in this section
Category / Section

How to change the height of a row in the WinForms GridGroupingControl?

2 mins read

Change the height of row


In the WinForms GridGroupingControl, when you change the height of a particular row, it affects the height of all the rows. You need a custom engine to resolve this problem. The custom engine is used to avoid the problem by passing the row index in the RowHeight property. In the GridModel, height of a single row is changed by using the GridEngineFactory class before invoking the InitializeComponent method.

 

By using GridModel

 

C#

GridEngineFactory.Factory=new Syncfusion.GridHelperClasses.AllowResizingIndividualRows();
InitializeComponent();

//Apply Rowheight to the Row 4.
this.gridGroupingControl1.TableModel.RowHeights[4] = 70;

VB

GridEngineFactory.Factory=New Syncfusion.GridHelperClas
ses.AllowResizingIndividualRows()
InitializeComponent()

'Apply Rowheight to the Row 4.
Me.gridGroupingControl1.TableModel.RowHeights(4) = 70

In the QueryRowHeight event, there is no engine needed to set the height of a single row because by default it supports the height change of a particular row.

 

By using QueryRowheight

 

C#

//used to prevent drawing glitches when the scrolling is fast
this.gridGroupingControl1.UseDefaultsForFasterDrawing = true;
this.gridGroupingControl1.TableModel.QueryRowHeight += TableModel_QueryRowHeight;

void TableModel_QueryRowHeight(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
{
  // Apply Rowheights to the even rows
  if (e.Index % 2 == 0)
  {
    e.Size = 35;
    e.Handled = true;
  }
}
VB
'used to prevent drawing glitches when the scrolling is fast
Me.gridGroupingControl1.UseDefaultsForFasterDrawing = True
AddHandler Me.gridGroupingControl1.TableModel.QueryRowHeight, AddressOf TableModel_QueryRowHeight

Private Sub TableModel_QueryRowHeight(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs)
 'Apply Rowheight to the even rows
 If e.Index % 2 == 0 Then
  e.Size = 35
  e.Handled = True
 End If
End Sub
After applying the properties, the row looks like the following screenshot


Changing the row height

Figure 1: Changing the row height

Samples:

C#: Changing the row height

VB: Changing the row height 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied