Hi,
I like to retrieve columns of a grid in the current visible order. The code below gives the columns in original order, but I like to have them in displayed order. How can I do that?
tia, Erik
UltraGridBand CurrentBand = Grid.DisplayLayout.Bands[0];for (int i = 0; i < CurrentBand.Columns.Count; i++){Column = (UltraGridColumn)CurrentBand.Columns.GetItem(i);if (Column.IsVisibleInLayout){ // do something }}
Hello Erik,
I believe that you can use VisiblePosition of the column header in order to get /set the visible position of the column. int position = this.ultraGridData.DisplayLayout.Bands[0].Columns["test"].Header.VisiblePosition;I hope this information was helpful.Best Regards,DimiDeveloper Support EngineerInfragistics Inc.
Using VisiblePosition is a bit tricky. Here's another way:
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; UltraGridColumn column = band.GetFirstVisibleCol(this.ultraGrid1.ActiveColScrollRegion, true); while (column != null) { Debug.WriteLine(column.Header.Caption); column = column.GetRelatedVisibleColumn(VisibleRelation.Next); }
Note that neither of these methods will work when using RowLayouts, since in a RowLayout, there really is no visible order - columns can span across or even overlap.
Hi Mike. Dimi,
Thank you both. I have got it working now like I wanted, using the VisiblePosition.
regards,
Erik