Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
UltraGrid - How to get column count
posted

This is what I'm currently doing to get the visible column count:

        Dim colTemp As UltraGridColumn = gridTemp.DisplayLayout.Bands(0).Columns(0)
        colTemp = colTemp.GetRelatedVisibleColumn(VisibleRelation.First)

        Dim nColCount = 0

        Do While colTemp IsNot Nothing
            colTemp = colTemp.GetRelatedVisibleColumn(VisibleRelation.Next)
            nColCount += 1
        Loop

Is there no easier way, like gridTemp.Columns.Count?

Thanks,

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    This will give you the total column count on the root band.

    gridTemp.DisplayLayout.Bands[0].Columns.Count

    If you only want the count of visible columns, you could do this:

    this.ultraGrid1.ActiveColScrollRegion.VisibleHeaders.Count;

    But the latter assumes that you are not using Groups, that your RowLayoutStyle is set to None, and that you are not using more than one ColScrollRegion with Exclusive columns.

Children