From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-22-2012 06:00 PM
Here's what I'm trying to do:
Have a multi-column listbox of elements. Allow the user to select a few rows he is interrested in (and the become highlighted). Allow sorting of the listbox by clicking on the column headers.
I've got the listbox populating fine, if nothing is selected, the sorting works fine (event structure based on mouseup event of the multi-column listbox, calling to the "get clicked column header" invoke node method sorts the data. The part that is not working is that If the user has elements selected, sorts the listbox, the same elements are selected (not the same rows, but those same elements in whatever row they ended up after being sorted).
What happens is if I select a few rows in the listbox (listbox configured for 0-N elements selectable, highlight entire row), and then click on the column header, the event structure fires off a value change event for the listbox and changes to no elements selected. if I then click the column header again, it fires off the mouse up event and I get the sorting, but now none of the rows are selected. Weird thing is that first time I click the column header and it fires the value change event, a call into get clickced column header returns negative value so it won't tell me which column header the user clicked to "empty" the selection.
Bugger!!!! doesn't work how I want it to.
Funny thing is if I change the listbox over to a 1-N elements selectable, and then select a few rows, and then click on the column header, the event structure fires off the mouse up event and I get the sorting and re-selecting exactly as I would expect.
What's the deal here?? is this a bug, or expected behavior. If it's expected, it would be nice if it were a little more consistent between the different types of listboxes. Also, any good suggestions as to how to allow users to have 0-N selected elements, and be able to sort the listbox and keep the selected rows selected?
02-22-2012 07:02 PM
Sounds annoying. Here is a variation of my goto method for these types of problems:
Use the MouseDown? event to catch important info like the old value.
Restore the old value at the end of the Mouse Up event.
Some details, like making sure that the down and up clicks are in the same cell.
Use Defer Updates to prevent flashing.
One of many kluges I have around for the MC Listbox....
10-31-2024 02:26 PM
Ran into this same old issue today...and noticed that this only happens if the selection mode is multiple items. It works as expected (without firing an invalid value change event) if the control only allows single selection / is a scalar.
This indicates to me that the behaviour really is a bug (an old one...). I do not see any reason why it should work this way, especially when it does not when the listbox is a scalar.