Search code examples
c#wpfxceed-datagrid

Can not add same column object into Xceed DataGrid


Good day!

I try to add the same column object into datagrid,but catch exception (with xaml).

 Column c = new Column();
 c.FieldName = "Text";
 c.Title = "Title";
 dgTable1.Columns.Add(c);
 dgTable2.Columns.Add(c); --exception.

Am i right, that i cannot do that- because i put reference of object "c" into method Add and when put it at another table-it throw exception?

So, to fix - need i to create c1 object and add this with Add method?

Thank you!


Solution

  • you can use the below mentioned code.

    for(int i=0;i<=2;i++)
    {
        Column c = new Column();
        c.FieldName = "Text";
        c.Title = "Title";
        dgTable1.Columns.Add(c);
     }