Listbox NotSortable?

I’ll post this under the beginners thread… since there’s a really good chance I’m making a noob mistake. I can’t seem to convince my listbox to be not sortable.
I don’t want the rows re-ordered…so I entered a line like this in the listbox open event.

me.HeaderType(-1) = Listbox.HeaderTypes.NotSortable

I also tried targeting individual columns to no avail. It seems my listbox just loves to be sortable and won’t take “no” for an answer.

HeaderType ought to work, and works on older RS versions. Sounds like a bug to me.

As a work around, set the ColumnSortDirection for each column to 0:

Sub Open()
   Me.ColumnSortDirection(0) = 0
   Me.ColumnSortDirection(1) = 0
  ' etc.
End Sub

Users will still be able to click on the column heading, but the column won’t be sorted.

This is <https://xojo.com/issue/27485>, which is fixed in 2013r2.

I’ve had the same issue. I put the list header stuff in the header pressed event ( i think it was list header) Worked fine. Sorry posting this on the road so can’t give the exact code but the header pressed event was the key for me.

Just return from the header pressed event

Thanks for the replies to all. I did understand that I should be able to write a “custom sort operation” for a column…so I speculated I could just write a handler that does nothing as Jym suggested. It did not occur to me that placing the NotSortable in the header click event might work. I did try placing it in a couple of locations as I thought perhaps it might not work in the Open event. Setting the sort direction to “0” is an interesting work around. I did of course check to make sure I was running the most up-to-date released version of XOJO. I guess that’s a reason to forward to 2013r2 :slight_smile:

Thanks to all those who took the time to comment. I believed what I was trying to do was the most simple and elegant method and I didn’t want to employ a workaround if it was just some silly misunderstanding on my part. It’s great to be part of this community. Hopefully I’ll have the opportunity to give back as I acquire more expertise. Thanks Again!

If you want those annoying arrows to disappear on a non-sortable listbox then this works in the HeaderPressed event

me.SortedColumn = -1 me.HasHeading = true return true