Home Forums WinForms controls Xceed Grid for WinForms Problem on dynamically creating a GridControl Reply To: Problem on dynamically creating a GridControl

User (Old forums)
Member
Post count: 23064

Hi André, thanks for your attention.

I figured out the problem with you tip. My problem was that my DataSource was a DataTable and NOT a DataSet… Now I have it right!

For improvements I tried out your Idea to set AutoCreateColumns to TRUE and delete the code that inserts manually all the columns and then use the SetDataBinding function. But it didn’t work.

gridGap.BeginInit();
{
    ColumnManagerRow cmrHeader = new ColumnManagerRow();
    gridGap.FixedHeaderRows.Add(cmrHeader);
    ((ColumnManagerRow) gridGap.FixedHeaderRows[0]).AllowColumnReorder = true;
 
    gridGap.AutoCreateColumns = true;
    gridGap.SetDataBinding(CurrentDataSet, CurrentTableName);
}
gridGap.EndInit(); 

this code doesn’t work, it gives me zero in gridGap.DataRows.Count. To fix it I HAD to create the columns manually.
To figure out what it could be, I tryed to creating columns manually with AutoCreateColumns true AND false and the result was the same…
It seems that, for me, AutoCreateColumns isn’t working at all.
Do you have any idea of what it could be?

(The problem is solved, but this AutoCreateColumns not working tricked me)

Thanks for the attention,
Oscar

 

Imported from legacy forums. Posted by Oscar (had 369 views)