Articles in this section

How to apply column sizer based on device orientation ?

SfDataGrid allows you to customize the SfDataGrid.ColumnSizer based on the requirement. You can apply different ColumnSizer based on orientation of the device and the SfDataGrid will rearrange the view accordingly.

Refer the below code example in which the SfDataGrid.ColumnSizer is customized based on orientation by checking the orientation of the device in the ViewLayoutSubViews override method of the ViewController which will be fired when the view changes.

 
public override void ViewDidLayoutSubviews()
{
    base.ViewDidLayoutSubviews();
    if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeLeft || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeRight)
        this.datagrid.ColumnSizer = ColumnSizer.Star;
    else
        this.datagrid.ColumnSizer = ColumnSizer.Auto;
    datagrid.Frame = new CoreGraphics.CGRect(0, 0, View.Frame.Width, View.Frame.Height );
           
}
 

 

The following screenshots shows the final outcome when the above code is executed.

Table

 

 

Sample Link:

How to apply column sizer based on device orientation?

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied