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.
Unfortunately, activation email could not send to your email. Please try again.

How to show multi-line header text in a SfDataGrid?

SfDataGrid allows you to customize the header text for a GridColumn by using the HeaderText property. However by default the grid displays only single line of text in the header and hence when you load a longer header text, the SfDataGrid clips them and displays an ellipsoid at the end.

 

In case, if longer text need to be displayed in the header, then SfDataGrid allows you to achieve it by creating a custom HeaderCellRenderer derived from HeaderCellRenderer. The custom HeaderCellRenderer replaces the default header view. Hence you can use it to load a label with LineBreakMode property being set to WordWrap. You can also decide the number of lines the text should display by setting the Lines property of the UILabel. You can use the HeaderRowHeight property to customize the header row height as required based on your header text.

 

Refer the following code example which illustrates how to show multiline header in SfDataGrid.

 

CustomHeaderCellRenderer.cs

 

Make sure you add the Custom Renderer to the SfDataGrid’s CellRenderers collection in your ViewController. Refer the following code example.

ViewController.cs

 

The following screenshot shows the final outcome on executing the above code.

 

You can download the working sample for this KB from the below link.

http://www.syncfusion.com/downloads/support/directtrac/general/ze/MultiLine1032256719

 

Article ID: Published Date: Last Revised Date: Platform: Control:
6209 02/03/2016 02/03/2016 Xamarin.iOS SfDataGrid
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.