TextAlignment Property (GridColumn)

Hi 
iam using xamarin.forms and sfdatagrid. 
Iam doing some testing with filling the sfdatagrid from datatable. 
It is working (little slow) but i need to format the cell textAlignment.
It is center default. 
I need to change the hole grid
and sometimes only some coloumns. 

if i look at:
https://help.syncfusion.com/cr/xamarin/Syncfusion.SfDataGrid.XForms.GridColumn.html#Syncfusion_SfDataGrid_XForms_GridColumn_TextAlignment
it only works if i manually create the columns. 

The querry iam using is dynamic so sometime theris 2 columns next time 10 columns. 

Iam using this:
var table = new DataTable();    
using (var da = new SqlDataAdapter(Dynamic_querry, "connection string"))
{      
    da.Fill(table); 
mygrid.itemsource= table;


1 Reply

SS Sivaraman Sivagurunathan Syncfusion Team April 3, 2020 11:27 AM UTC

Hi Jonas, 

Thanks for using Syncfusion controls. 

We have checked your query. You can achieve your requirement by AutoGeneratingColumn. You need to set the GridColumn TextAlignment property in the AutoGeneratingColumn. We have prepared the sample for your requirement and attached for your reference. You can download the same from the below link.  

Code Example: 
Xaml 
<syncfusion:SfDataGrid x:Name="Grid"  
                        ColumnSizer="Star"  
                        ItemsSource="{Binding Records}" 
                        AutoGenerateColumns="True" 
                        AutoGeneratingColumn="Grid_AutoGeneratingColumn"> 
</syncfusion:SfDataGrid> 

Code Behind 
private void Grid_AutoGeneratingColumn(object sender, AutoGeneratingColumnEventArgs e) 
{ 
    e.Column.TextAlignment = TextAlignment.Start; 
} 




Regards, 
Sivaraman S 


Loader.
Up arrow icon