Skip to content

Replies

0
Malgorzata
Malgorzata answered on Jan 14, 2009 10:42 AM

 I hope I solved the problem – the datatable should be created as a new object every time I want to change the columns in grid group.

0
Malgorzata
Malgorzata answered on Jan 14, 2009 10:02 AM

Hi,

 I have the same problem as Karen, I tried to solve it as you wrote in the post, but it doesn't work:( It's my code :

dataTable is of type DataTable. I want only to get rid of these grid columns, which have index greater than 2. When I launch my form, it works fine, but if I reload it because of data change, it throws an exception attached. It seems this exception occurs in grid.OnPaint event It's my code: 

UltraGridBand band = grid.DisplayLayout.Bands[0];
UltraGridGroup group = band.Groups[1];
UltraGridColumn col;
for (int i = 3; i < dataTable.Columns.Count; i++)
{
        String colKey = dataTable.Columns[i].Caption;
        if (!grid.DisplayLayout.Bands[0].Columns.Exists(colKey))
        {
             col = grid.DisplayLayout.Bands[0].Columns.Add(colKey);
             col.DataType = typeof(decimal);
         }
         else
             col = grid.DisplayLayout.Bands[0].Columns[colKey];
               
         if (!group.Columns.Exists(colKey))
             col.Group = group;
}

Thanks,

~Gosia