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

How to set right margin in the Header in SfDataGrid?

Platform: Xamarin.iOS |
Control: SfDataGrid
Tags: formatting



In SfDataGrid, when you set TextMargin in GridColumn, it will apply the margin only for the record cells and not the header cells. However, you want to set the TextMargin in header, to override the GridHeaderCellRenderer, and append some spaces to the text of UI Label following a period and make the color of the period appended at the end of the transparent, such that it will be look like text is set with some margin at the right end. Otherwise we include transparent period at the end of the string after the spaces and set the TextMargin based on the record cells.

In following code sample ensure that the text is set with the margin at right end.               



Refer the following screenshot that shows the final outcome on execution of the above code.



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

Right margin in header



2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Jan 08, 2017
The signature for GridHeaderCellRenderer.OnInitializeDisplayView seems to have changed in a recent release and does not work in

OnInitializeDisplayView(DataColumnBase dataColumn, UILabel view) is now OnInitializeDisplayView(DataColumnBase dataColumn, UIView uiView)

UILabel parameter has been replaced with UIView parameter.

Do you have an updated solution for the new signature?
Divakar Subramaniam [Syncfusion]
Jan 11, 2017
Hi Justin,

We have modified both the code as well as the sample. Please ensure it.


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile