Articles in this section
Category / Section

How to customize ColumnSizer based on orientation in SfDataGrid?

2 mins read

The SfDataGrid allows you to customize the SfDataGrid.ColumnSizer based on orientation by using the SfDataGrid.SizeChanged event. It automatically refreshes the view based on the ColumnSizer when orientation is changed.

public void dataGrid_SizeChanged(object sender, EventArgs e)
{
    //Orientation is Landscape. Hence setting ColumnSizer as "Star".
    if (dataGrid.Width > dataGrid.Height)
        dataGrid.ColumnSizer = ColumnSizer.Star;
    //Orientation is Portrait. Hence setting ColumnSizer as "Auto".
    else
        dataGrid.ColumnSizer = ColumnSizer.Auto;
}

 

Screenshot:

       Orientation: Portrait                                                Orientation: Landscape

C:\Users\suhasini.suresh\AppData\Local\Microsoft\Windows\INetCacheContent.Word\Screenshot_2017-01-23-14-21-05_CustomizeColumnSizer.Droid.png

Sample Link:

How to customize ColumnSizer based on orientation in SfDataGrid

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
Access denied
Access denied