|
1 | | -# How-to-refresh-the-row-height-programmatically-in-.NET-MAUI-DataGrid--SfDataGrid- |
2 | | -This demo shows how to refresh the row height programmatically in .NET MAUI DataGrid (SfDataGrid) ? |
| 1 | +# How to refresh the row height programmatically in .NET MAUI DataGrid (SfDataGrid) ? |
| 2 | +In this article, we will show you how to refresh the row height programmatically in [.NET MAUI DataGrid](https://www.syncfusion.com/maui-controls/maui-datagrid). |
| 3 | + |
| 4 | +## xaml |
| 5 | +``` |
| 6 | +<ContentPage.BindingContext> |
| 7 | + <local:EmployeeViewModel x:Name="viewModel" /> |
| 8 | +</ContentPage.BindingContext> |
| 9 | + |
| 10 | +<syncfusion:SfDataGrid x:Name="sfGrid" |
| 11 | + GridLinesVisibility="Both" |
| 12 | + HeaderGridLinesVisibility="Both" |
| 13 | + AutoGenerateColumnsMode="None" |
| 14 | + QueryRowHeight="sfGrid_QueryRowHeight" |
| 15 | + ItemsSource="{Binding Employees}"> |
| 16 | +
|
| 17 | + <syncfusion:SfDataGrid.Columns> |
| 18 | + <syncfusion:DataGridNumericColumn MappingName="EmployeeID" |
| 19 | + Format="#" |
| 20 | + HeaderText="Employee ID" /> |
| 21 | + <syncfusion:DataGridTextColumn MappingName="Name" |
| 22 | + HeaderText="Employee Name" /> |
| 23 | + <syncfusion:DataGridTextColumn MappingName="Title" |
| 24 | + HeaderText="Designation" /> |
| 25 | + <syncfusion:DataGridDateColumn MappingName="HireDate" |
| 26 | + HeaderText="Hire Date" /> |
| 27 | +
|
| 28 | + </syncfusion:SfDataGrid.Columns> |
| 29 | +
|
| 30 | +</syncfusion:SfDataGrid> |
| 31 | +``` |
| 32 | + |
| 33 | +## Xaml.cs |
| 34 | +The code below demonstrates how to refresh the row height programmatically in the QueryRowHeight event of SfDataGrid. |
| 35 | +``` |
| 36 | +private void sfGrid_QueryRowHeight(object sender, Syncfusion.Maui.DataGrid.DataGridQueryRowHeightEventArgs e) |
| 37 | +{ |
| 38 | + if (e.RowIndex > 0) |
| 39 | + { |
| 40 | + e.Height = e.GetIntrinsicRowHeight(e.RowIndex); |
| 41 | + e.Handled = true; |
| 42 | + (sender as SfDataGrid).InvalidateRowHeight(e.RowIndex, true); |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +<img src="https://support.syncfusion.com/kb/agent/attachment/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM1ODMxIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.xZVPkjhEEs9zD1jeqE_bzi53n_rgQmeN5v6okG8A1Mg" width=700/> |
| 48 | + |
| 49 | +[View sample in GitHub](https://github.com/SyncfusionExamples/How-to-refresh-the-row-height-programmatically-in-.NET-MAUI-DataGrid--SfDataGrid-) |
| 50 | + |
| 51 | +Take a moment to explore this [documentation](https://help.syncfusion.com/maui/datagrid/overview), where you can find more information about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this [link](https://www.syncfusion.com/maui-controls/maui-datagrid) to learn about the essential features of Syncfusion .NET MAUI DataGrid (SfDataGrid). |
| 52 | + |
| 53 | +##### Conclusion |
| 54 | + |
| 55 | +I hope you enjoyed learning about how to refresh the row height programmatically in the .NET MAUI DataGrid (SfDataGrid). |
| 56 | + |
| 57 | +You can refer to our [.NET MAUI DataGrid’s feature tour](https://www.syncfusion.com/maui-controls/maui-datagrid) page to learn about its other groundbreaking feature representations. You can also explore our [.NET MAUI DataGrid Documentation](https://help.syncfusion.com/maui/datagrid/getting-started) to understand how to present and manipulate data. |
| 58 | +For current customers, you can check out our .NET MAUI components on the [License and Downloads](https://www.syncfusion.com/sales/teamlicense) page. If you are new to Syncfusion, you can try our 30-day [free trial](https://www.syncfusion.com/downloads/maui) to explore our .NET MAUI DataGrid and other .NET MAUI components. |
| 59 | + |
| 60 | +If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://support.syncfusion.com/create) or [feedback portal](https://www.syncfusion.com/feedback/maui?control=sfdatagrid), or the feedback portal. We are always happy to assist you! |
0 commit comments