Home / Community & Support / Knowledge Base / RadControls for WinForms / GridView / Change the height of expanded child view in hierarchical RadGridView

Change the height of expanded child view in hierarchical RadGridView

Article Info

Rating: 5

Article information

Article relates to

 RadGridView for WinForms, Q2 2010

Created by

 Martin Vasilev

Last modified

July 19, 2010

Last modified by

 Alexander Georgiev, Telerik


HOW-TO
Change the height of child view in hierarchical RadGridView

SOLUTION
The height of child view is defined automatically when the RadGridView property UseScrollbarsInHierarchy is set to true. It is its default value. You can set it to false and resize the child views using the UI or set its height using code.

It could be used the row header to resize it manually by following next steps:

        1) Position the mouse cursor at the bottom of the expanded row in the row header column 
        2) Click the left mouse button 
        3) Drag the mouse up and down

Another possibility is to specify the height explicitly through code by using the RowFormatting event:

VB code:
Me.radGridView1.UseScrollbarsInHierarchy = True
Me.radGridView1.RowFormatting += New RowFormattingEventHandler(radGridView1_RowFormatting
  
Private Sub radGridView1_RowFormatting(sender As Object, e As RowFormattingEventArgs)
    Dim hierarchyRow As GridViewHierarchyRowInfo = TryCast(e.RowElement.RowInfo, GridViewHierarchyRowInfo)
    If hierarchyRow IsNot Nothing AndAlso hierarchyRow.ChildRow IsNot Nothing Then
        Dim customHeight As Integer = 1000
  
        hierarchyRow.ChildRow.MaxHeight = customHeight
        hierarchyRow.ChildRow.Height = customHeight
    End If
End Sub

C# code:

this.radGridView1.UseScrollbarsInHierarchy = true;
this.radGridView1.RowFormatting += new RowFormattingEventHandler(radGridView1_RowFormatting);
 
private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
    GridViewHierarchyRowInfo hierarchyRow = e.RowElement.RowInfo as GridViewHierarchyRowInfo;
    if (hierarchyRow != null && hierarchyRow.ChildRow != null)
    {
        int customHeight = 1000;
 
        hierarchyRow.ChildRow.MaxHeight = customHeight;
        hierarchyRow.ChildRow.Height = customHeight;
    }
}

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.