Dumb question: how to avoid sorting a listbox when the user clicks on the headers?
BTW I can of course reload the listbox when the user clicks on the header, (I would call this a workaround. But surely there should be a better way.
Dumb question: how to avoid sorting a listbox when the user clicks on the headers?
BTW I can of course reload the listbox when the user clicks on the header, (I would call this a workaround. But surely there should be a better way.
I’m getting old …
But it still shows the ^ icons in the header when pressed. Any way to disable this too?
Yes, there is. Where , How ?
I put that in a MenuEvent to remove the small Sort icon. Thanks to the Xojo Engineer tip.
LB.SortedColumn = -1
LB.HasHeading = False
LB.HasHeading = True
The simplest way is to prevent the action from being called.
me.HeaderType(0)=Listbox.HeaderTypes.NotSortable
I forgot that one
This question occurred to me when I wanted to do a “Select all” by pressing the header column 4. I managed this with a computed property:
[code]Private isExportAll As Boolean
Get
Return misExportAll
End Get
Set
misExportAll = value
if value = true then
lbUebungen.SortedColumn = -1
lbUebungen.HasHeading = false
lbUebungen.HasHeading = true
isExportAll = False
end if
End Set
End Property[/code]
Then, in the event HeaderPressed:
[code]Function HeaderPressed(column as Integer) As Boolean
if column = 4 then
if isExportAll then
return false
end if
// … Do what you want to be accomplished
// Sort-Indikator ausschalten
isExportAll = true
end if
End Function[/code]
Just WHY?
All the columns are sorted
Read there: ListBox.SortColumn to learn how to avoid Sorting a Column from a Listbox.
There is no artwork to watch, but only a few lines to read.
Quite an elegant solution. Thanks for sharing.