04-13-2016 11:30 PM
In an effort to scroll a front panel window (pane) that contains a listbox which is much bigger than the window, I need to get the number of the currently-highlighted row within the listbox and adjust the window scroll (origin) position accordingly. I want to be able to move from row to row within the listbox using the up/down arrow keys on the keyboard. So far all that can be made to work fairly easily. But once some (or perhaps many) of the rows within the listbox become disabled rows, the value that gets reported out for them is always "-1". Using the arrow keys it is possible to move the selected row pointer to a disabled row and while it does not become highlighted like an enabled row, a ghost rectangle does appear around it to show that some part of LabVIEW does have a sense that the listbox pointer is at that row anyway.
I have looked at and observed the behavior of every listbox property that I thought even might remotely be able to give me the sense of the row number (ghost pointer) when the row is disabled but so far I've come up empty. Suggestions?
04-14-2016 03:19 AM - edited 04-14-2016 03:27 AM
Rather than making the listbox much larger than the pane and then scrolling the pane, I would suggest making the listbox fit the pane and then maybe change the top row property of the listbox to scroll it. Once you do that, as far as I can tell, you shouldn't actually have a problem or need to do anything, because the listbox scrolls automatically when the user navigates it, which is why that "maybe" is there. You can also show the scroll bar on it to make it easier for the user.
I did mention the top row property, because there are times when you do want to change the position yourself and then it is useful (such as if you're adding an item to the list and want to highlight it). If you do that, there are some edge cases around the start and end of the listbox you will want to handle (such as doing a min and max with zero).
Incidentally, if for some reason I would still need to control it myself, I think I would probably use the Key Down? event for the listbox and track the current value separately in a shift register. Whenever the value of the listbox is -1, I would handle incrementing or decrementing it myself.
Also, relevant plug - http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Setting-the-value-of-a-listbox-should-display-the-sele...
04-14-2016 08:50 AM - edited 04-14-2016 08:52 AM
@tst wrote:Rather than making the listbox much larger than the pane and then scrolling the pane, I would suggest making the listbox fit the pane and then maybe change the top row property of the listbox to scroll it. Once you do that, as far as I can tell, you shouldn't actually have a problem or need to do anything, because the listbox scrolls automatically when the user navigates it, which is why that "maybe" is there. You can also show the scroll bar on it to make it easier for the user.
:
:
Incidentally, if for some reason I would still need to control it myself, I think I would probably use the Key Down? event for the listbox and track the current value separately in a shift register. Whenever the value of the listbox is -1, I would handle incrementing or decrementing it myself.
This is what I started out with initially and for a variety of reasons did not care for it. I may have to go back to it but for now would like to try to make this other work.