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

Determine Aligment, Font, Size in Syncfusion Xamarin Android SfDataGrid As A Programmatically in C#

I've created the different observablecollection inluding different class.
Each binding list model to SfDataGrid, I want to determine each datagrid cell text alignment, cell font size, header text, etc. only programmatically in C# side.
How can I achieve this?

3 Replies

KK Karthikraja Kalaimani Syncfusion Team November 19, 2019 05:22 PM UTC

Hi Xamarin Hunter, 

Thanks for contacting Syncfusion support.

Your requirement can be achieved by using AutoGeneratingColumn event of SfDataGrid. We have prepared sample for the same.

Please follow the below code example, 
  private void SfdataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e) 
        { 
            if (e.Column.HeaderText == "OrderID") 
            { 
                e.Column.CellTextSize = 20; 
                e.Column.TextAlignment = GravityFlags.End; 
                e.Column.HeaderText = "Customized OrderID"; 
            } 
        } 

We hope this helps, please let us know if need further assistance from us. 

Regards, 
Karthik Raja 



XH Xamarin Hunter replied to Karthikraja Kalaimani November 24, 2019 03:44 PM UTC

Hi Xamarin Hunter, 

Thanks for contacting Syncfusion support.

Your requirement can be achieved by using AutoGeneratingColumn event of SfDataGrid. We have prepared sample for the same.

Please follow the below code example, 
  private void SfdataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e) 
        { 
            if (e.Column.HeaderText == "OrderID") 
            { 
                e.Column.CellTextSize = 20; 
                e.Column.TextAlignment = GravityFlags.End; 
                e.Column.HeaderText = "Customized OrderID"; 
            } 
        } 

We hope this helps, please let us know if need further assistance from us. 

Regards, 
Karthik Raja 


Thanks for exact solution.


FP Farjana Parveen Ayubb Syncfusion Team November 25, 2019 05:04 AM UTC

Hi Xamarin Hunter, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Farjana Parveen A 


Loader.
Up arrow icon