In my code I am populating a grid from a datatable using SetDataBinding. Then I want to loop through the grid and get the column order that I set in the grid designer. However when I loop, I get the order that is in the datatable and not what I setup in the grid designer. What am I doing wrong?
ugPenaltyTable.SetDataBinding(m_dsPenaltyMonitor.dtPenalty.DefaultView, "");
Infragistics.Win.UltraWinGrid.ColumnsCollection c = ugPenaltyTable.DisplayLayout.Bands[0].Columns;
foreach (UltraGridColumn column in c){ if (column.Hidden == false) { strData.Append(column.Header.Caption + "\t"); }}
Changing the visible order of the columns does not change their position in the collection.There are a couple of ways you can get the columns in their visible order.
The easiest would be to use grid.ActiveColScrollRegion.VisibleHeaders.
Another way would be to use the GetFirstVisibleColumn method on the band, then use GetRelatedVisibleColumn on each column to loop.
Mike,
I have similar problem and your suggestion seems not to work for me.
The issue is that i'm using a DrawFilter to draw something on the first column in the first row.
I need to get the first column name, but using the code you have suggested i'm not getting the column name - i assume this is becuase it is not yet visible since it becomes visible only when a group by row is being expanded.
How do i get the order of the columns not in the data set.. - the actual order of the columns in the grid's layout...
Thanx,
Gili
Hi Gili,
Try:
band.GetFirstVisibleColumn
Thanx!
That did the jobs :-)
-Gili