From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Listbox scroll event is not captured when clicked on the scrollbar and dragged

Hi all,

 

I need to synchronize the scroll position of 2 listboxes for our project. The "Mouse Wheel" event detects the scrolling when the user wheels the mouse or when the user clicks on up/down arrows in the scrollbar. But this event is NOT detected when the user clicks on a scrollbar and drags it and then leaves it. So in this case the 2 listboxes are not synchronized. Please do suggest if there is any solution to it.

 

A standalone scrollbar has a "Value Change" event to detect the change even when the user clicks on the bar & drags it. But using this standalone scrollbar is not an option since it does not allow customization (change the color and increase the width for the touchscreen application).

 

Thanks,

Priyadarsini S

0 Kudos
Message 1 of 5
(2,774 Views)

If the scroll bar click generates a “mouse down” event, you may be able to something like this:

Mouse down -> determine scroll bar location -> store this value
Mouse up -> determine scroll bar location -> compare to previously stored value

If the values are the same, no action required. If the values have changed, perform action to synchronize the scrollbar of the other listbox.

0 Kudos
Message 2 of 5
(2,747 Views)

You can try using a .NET scrollbar, if a standalone scrollbar is what you prefer.  These seem to be customizable using property nodes.  Unfortunately, I can't help you any further than this, in regards to registering for events and such. 

 

Listboxes have a method called Point to Row.  Inside the Mouse Down event, use this method to see if the mouse click occurred within the bounds of the listbox content rectangle.  If not, the event occurred either on the border of the listbox or in it's scrollbar area.  Use this information in a Mouse Move event to update the synchronization.  And then stop the synchronization upon mouse up or mouse leave. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 5
(2,733 Views)

Hi playerm1,

 

Yes, that is 1 workaround. But do keep in mind if the user moves the mouse outside the listbox while scrolling & releases the mouse there, then the mouse up event will not be triggered for the listbox. But that can also be worked around by capturing the "mouse up" for the pane. It is still a too much of programming.

 

Thanks,

Priyadarsini S

0 Kudos
Message 4 of 5
(2,709 Views)

Hi aputman,

 

Yes, that is the way to proceed. For now, we are using the LabVIEW listbox native scrollbar itself.

 

Thanks,

Priyadarsini S

0 Kudos
Message 5 of 5
(2,706 Views)