)
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 change the height of a row in the WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: February 9, 2015 |
Last Revised Date: February 12, 2020

Change the height of row

In the 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.GridHelperClasses.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#

//In Form_Load
//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

'In Form_Load
'used to prevent drawing glitches when the scrolling is fast
Me.gridGroupingControl1.UseDefaultsForFasterDrawing = True
Me.gridGroupingControl1.TableModel.QueryRowHeight += 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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Sergei Leschinksy
Apr 19, 2015
When color editors (and presumably other editors are in place) the second approach will result in heavy drawing glitches when grid rows are scrolled fast. This can be be reproduced with the code below. The first approach works fine in such scenario. public Form1() { InitializeComponent(); gridGroupingControl1.DataSource = GetDataSource().Select(item => new { Color = item }).ToList(); ; gridGroupingControl1.TableModel.QueryRowHeight += TableModel_QueryRowHeight; } void TableModel_QueryRowHeight(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e) { if (e.Index%2 == 0) { e.Size = 35; e.Handled = true; } } private IEnumerable GetDataSource() { var arr = Enum.GetValues(typeof (KnownColor)); return from KnownColor item in arr select Color.FromKnownColor(item); } Reply
Venkatesh Sundaram [Syncfusion]
Apr 21, 2015
Hi Sergei, We regret the inconvenience caused. Thanks for pointing this out. The “drawing glitches raised when grid rows are scrolled fast” can be resolved by using the UseDefaultsForFasterDrawing property. Please refer to the following code snippet. CodeSnippet[C#]: this.gridGroupingControl1.UseDefaultsForFasterDrawing = true; The KB article is modified now with the needed information. Please let us know if you have any other concern. Thanks and Regards, Venkat Reply

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