Articles in this section
Category / Section

How to set the RowHeight to a specific row?

1 min read

SfDataGrid allows you to set the RowHeight to specific row by using VisualContainer.RowHeights property.

The following code example explains how to set the RowHeight to a specific row.

C#

using Syncfusion.UI.Xaml.Grid.Helpers;
 
this.sfdatagrid.Loaded += sfdatagrid_Loaded; //Event Hooking
void sfdatagrid_Loaded(object sender, RoutedEventArgs e)
{
    var VisualContainer = this.sfdatagrid.GetVisualContainer();
    //Set RowHeight to 2'nd row
    VisualContainer.RowHeights[2] = 50;
    VisualContainer.InvalidateMeasure();
}

 

You can also use QueryRowHeight event to set the row height for a specific row. Refer to the following code example for the QueryRowHeight event.

C#

this.sfdatagrid.QueryRowHeight += sfdatagrid_QueryRowHeight; //Event Hooking
void sfdatagrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e)
{
    if (e.RowIndex == 2) //Set RowHeight to 2'nd row.
    {
        e.Height = 50;
        e.Handled = true;
    }
}

 

Note:

Use QueryRowHeight event only when you want to change the height for all rows based on certain conditions.

 

The following screenshot displays the output for setting RowHeight as 50 to a specific row.

setting RowHeight as 50 to a specific row.

Sample Links

WPF

WRT

UWP

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment