Hello,
I have this line in BeforeSortColumn and AfterSortColumn event code:
m_LastSortColumn =
Me.UltraGrid1.DisplayLayout.Bands(e.Band.Index).Columns(e.SortedColumns(index).Key)
e.SortedColumn(index).Key correctly reports the Key. e.SortedColumn(index).Index returns -1 instead of the actual column index. Is this a bug in the event args?
I assume you mean BeforeSortChange and AfterSortChange, as the event names you are using here do not exist.
Which event exactly is giving you a -1 for the index? Both?
The SortedColumn collection in the event args represents two different things depending on which event you are using, so it's hard to say without knowing which event you are referring to.
And what index are you passing in?
Is the column visible?
Hello Mike,
Thank you for the response! I apologize for the mistaken event names. You are correct, I meant the Before/AfterSortChange events. The column is visible. I set an UltraGridColumn variable based upon this code:
Me
.UltraGrid1.DisplayLayout.Bands(e.Band.Index).Columns(e.SortedColumns(index).Key)
If I use e.SortedColumns(index).Index, it returns -1. If I use e.SortedColumns(index).Key, it correctly returns the Key. The index variable is just used to iterate the SortedColumns collection and varies from 0 to count - 1.
Shouldn't e.SortedColumns(index).Index return the actual grid column index?
I had to change to use Key in both of the events while iterating the SortedColumns collection.