ListBox SelectedRowIndex is wrong after adding a row to a sorted list
- Status
- Fixed
- Fixed in
- v26.10.2
- Area
- desktop
- Source discussion
- https://forum.objo.dev/d/1304-listbox-rowtag-mixed-up-in-sorted-list
- Last updated
- 2026-10-12
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
When a ListBox has an active sort (set with Sort() or by clicking a column header), rows added afterwards appear on screen in their sorted position, but the ListBox then reports the wrong selected row. SelectedRowIndex returns the row's on-screen position instead of the row number used by RowTag, CellTextAt, RemoveRow and the other row APIs, so the documented pattern of reading SelectedRowIndex and passing it to RowTag returns the tag belonging to a different row. Setting SelectedRowIndex has the same problem in reverse: the value is interpreted as an on-screen position rather than a row number.
Expected behaviour: row numbers mean the same thing in every ListBox API, including while a sort is active.