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. Image for the cookie policy date

How to set datagrid height to auto?

How can I set the height of the datagrid as auto? I want the datagrid height to follow the contents of the grid. I don't want scrolling on my grid. I want it to generate the grid with height according to the contents of the gird.

1 Reply

IM Indhumathy Malayappan Syncfusion Team August 4, 2017 11:21 AM UTC

Hi Gangatharan Baskaran,

Thank you for contacting Syncfusion Support,

I have checked your query and you can set the height of the datagrid based on the content by using the following way and you can also know the height of the datagrid by multiplying the records count with rowheight and then add th
e header row height to it.

Refer the below codes for your reference,
 
private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e)
{
    var height = (dataGrid.View.Records.Count * dataGrid.RowHeight) + dataGrid.HeaderRowHeight;
 this.SfGrid.HeightRequest = (double)height;
} 

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo-1621419080

Please note that this method is not effective when you are using QueryRowHeight since each row height varies. Please revert us if you have any other concerns.

Regards,

Indhumathy M

 


Loader.
Up arrow icon