Hi Iain,
We have analyzed your query. We regret to inform you that, we can’t get the column count in AutoGenratingColumn event because columns are added in the DataGrid.Columns Collection only after all columns are generated. We suggest to use separate field to maintain ColumnCount in AutoGenratingColumn event otherwise you can get the column count in ItemsSourceChanged event as like below code example.
this.datagrid.ItemsSourceChanged += Datagrid_ItemsSourceChanged;
private void Datagrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e)
{
var sfDataGrid = e.OriginalSender as SfDataGrid;
var columnCount = sfDataGrid.Columns.Count;
} |
We have prepared the sample as per your requirement, you can download the same from below mentioned location.
Sample location.
Please let us know if you have any further assistance on this.
Regards,
Gnanasownthari T.