LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically change selected cell/row of multicolumn listbox

Solved!
Go to solution

I want to programmatically change the selected cell of a multicolumn list box whose Selection Mode is set to Highlight Entire Row.  I would use this to be able to highlight which ever row of the listbox I choose to.  It would function in the same manner as if the user had clicked on a row to select it and highlight that particular row.  Setting the Active Cell does not accomplish this.

 

Steve

 

0 Kudos
Message 1 of 15
(10,965 Views)
Solution
Accepted by SteveP

Try using the value property 😜

Message 2 of 15
(10,955 Views)

Assigning the Value property works to change the selected and highlighted row.  Thanks

0 Kudos
Message 3 of 15
(10,944 Views)

What if the Multi-column listbox value exceeds the visible number of rows? Is there a way to automatically scroll down with the value being set?

0 Kudos
Message 4 of 15
(8,411 Views)

@rkmadse wrote:

Is there a way to automatically scroll down with the value being set?


Yes and no. There is nothing built in, but you can use the Top Left Visible Cell property to set this. While you can simply use this with your cell, it generally looks better if you set it to a few rows above and there are edge cases around the start and end of the listbox.


___________________
Try to take over the world!
Message 5 of 15
(8,389 Views)

Not really selected in the strict sense.

 

I does highlight the row(s) but they aren't ("completely") selected: You can't extend the selection by shift-click (but you can by ctrl-click...) 😮

 

It needs a mouse click to start/end the selection, which is indicated indicated by a dotted box around where you selected.

 

Go figure...

 

MGiacomet_0-1688566591527.png

 

Message 6 of 15
(1,648 Views)

@MGiacomet wrote:

I does highlight the row(s) but they aren't ("completely") selected: You can't extend the selection by shift-click..


With a bit of playing, it looks like the Focus Row property does do what you want (if you shift-click after setting it, the selection block will start from that row), but you will still need to decide which row is the one you actually want to start from.

 

Can't say that I ever needed this personally. I think that in cases where I needed to track and mark mutiple things in a MCLB it was usually either OK to let the user Ctrl+click as much as needed (or I simulated a Ctrl press when entering the control and a release when leaving in the cases where holding down Ctrl was not a viable option) or I tracked the selection by cell and not by row in a separate data structure and used the cell colors to indicate the selection to the user rather than the value of the control.


___________________
Try to take over the world!
Message 7 of 15
(1,622 Views)

You mean, like in the pic below? Still doesn't do it...

 

The intent in this example (and I believe the OP) is to programmatically select row three and, as in any Windows, etc. application, based on the "selected" row as indicated by the highlight, be able to extend the selection to, say, row 5 by shift-clicking on it. The result should be rows 3, 4, and 5 selected. However when you shift-click on row 5, only it becomes selected (and then it has the dotted box around it indicating the start of the actual selection...)

 

It appears that the MCLB needs a mouse click to start the (actual) selection.

 

 

MGiacomet_0-1688647952525.png

 

 

 

Furthermore, Help for the property property FocusRow says "The row that has focus and is used as the basis for key navigation such as up and down arrows", but after calling the property up and down arrows do NOT work! One must (again) mouse click on a row to be able to use up/down arrows.

0 Kudos
Message 8 of 15
(1,607 Views)

@MGiacomet wrote:

You mean, like in the pic below? Still doesn't do it...

when you shift-click on row 5, only it becomes selected (and then it has the dotted box around it indicating the start of the actual selection...)

 

 

MGiacomet_0-1688647952525.png


Your MCLB datatype is defined as a scalar (selection mode 0 or 1 item or 1 item). I don't think in this case you can select multiple rows in any configuration, regardless of how many times you shift click. Change the selection mode to be 0 or more and then it should work.

 

 


@MGiacomet wrote:

 

Furthermore, Help for the property property FocusRow says "The row that has focus and is used as the basis for key navigation such as up and down arrows", but after calling the property up and down arrows do NOT work! One must (again) mouse click on a row to be able to use up/down arrows.


Your MCLB doesn't have the key focus, so pressing the keys will not affect it. You can set the focus row property and then set the key focus property to true (or mouse click on it like you did) and then it should work.


___________________
Try to take over the world!
0 Kudos
Message 9 of 15
(1,538 Views)

>>Your MCLB datatype is defined as a scalar (selection mode 0 or 1 item or 1 item

Ok, my bad in the pic; but the (wrong) behavior is the same even if set for multiple selection

 

>>Your MCLB doesn't have the key focus

Setting Key Focus puts an extra border around the MCLB, which isn't shown (or needed) once you do a mouse click to start the selection

0 Kudos
Message 10 of 15
(1,520 Views)