According to the manual calling PressHeader should not sort.
ListBox.PressHeader ( Column as Integer )
Causes the specified ListBox header to be pressed, causing a HeaderPressed event to occur.
Column is zero-based. Calling this method does not update the sort direction.[/quote]
In my code , I put a breakpoint at that line, and then a breakpoint in the comparerows event of the listbox.
Calling pressheader fires the comparerows, which is not what I expected based on the manual.
Am I misunderstanding something here, or is the manual wrong?
From the language reference:
[quote]ListBox.HeaderPressed ( Column as Integer ) As Boolean
If you return True, the column is not sorted and it does not update the SortedColumn property.[/quote]
Yes, I know. Workaround is easy enough.
When calling PressHeader from code, I now set a boolean (bPressedHeaderFromCode) property I added to true, and then in headerpressed I set it back to False if it is true and return True.
If I would always return true in HeaderPressed, it would not work when pressing the header either, which is not what I want.
I still, based on the language of the manual, expected the sort not to happen when calling PressHeader from code.
That’s not a work-around, that’s the correct way to do it.
I don’t know how to read this then.
The method PressHeader simulates a mouse click on the header - it does not do anything else.
“Does not update the sort direction” means it doesn’t change the visual indicator. It doesn’t say it doesn’t sort. This allows you to sort the column without having that pesky arrow appear next to the column header.