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: 

How do you drag and drop columns in a multicolumn listbox?

Hello,

Im trying to have a multicolumn listbox setup so that you could select a column, and drag it to another location so that the use would be able to rearrnage the table if they so pleased. I've tried looking for a few different ways to do this, but I havent found anything yet. Is there a way that this can be done?

Thanks,
Mark
0 Kudos
Message 1 of 12
(4,614 Views)
Try this LabVIEW example: "labview\examples\general\dragdrop".
0 Kudos
Message 2 of 12
(4,557 Views)
Thanks for the reply, but none of those had a multicolumn listbox in them...
0 Kudos
Message 3 of 12
(4,545 Views)
Hey, Drag and Drop - Built-in Source Custom Data.vi is a good example of how to do drag and drop.  The same process applies for multicolumn listboxs.  You can just change out the objects used in the example with what you are trying to use.
 
Hope this helps!
 
Dan
Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 4 of 12
(4,536 Views)
Thanks Daniel, but as well that was'nt quite what I was looking for. Perhaps I didn't quite explain it right.

Here is a more detailed idea of what I would like to do...
I would like to be able to have either a multicolumn listbox or table with data in it that will be placed there by the program.
Lets say that this table has 4 columns.
The user would be able to click on the header of column 4, click and drag over in between column 1 and 2, and 'drop' it there.
This would make what was in column 4, now in column 2. 2 would move to 3, and 3 would shift over to 4.

If I need to clarify this anymore, please let me know.

Thanks again!
0 Kudos
Message 5 of 12
(4,534 Views)

Hey, see the attached examples.  I modified the example mentioned earlier.  You basically use a invoke node to get the position of the mouse cursor when the drag starts.  This allows you to know what column you are dragging.  Then you do the same when the "drop" event happens.  This allows you to know where you want to drop the event.  Then you have to program in the change in the listbox's strings.  That is at least how I have done it in the past.

 

Let me know if this helps.

 

Dan

Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
Download All
0 Kudos
Message 6 of 12
(4,514 Views)

Thanks for the help Daniel!

I defiantly have something working now… but it seems like I can not drag and drop from the headers. I can drag and drop from the data in the cells, but I would really like to be able to drag from the columns header.

 

Did you have yours setup in a way where this worked? I’ve tried messing around with a few things, but with no luck so far. I suppose I can always manually set it up not show the headers, and have the top row formatted different from the rest, and as a result it would look like the header… but I’d rather not have to make the program keep track of that if it really isn’t needed. Any suggestions?


Thanks again!

0 Kudos
Message 7 of 12
(4,507 Views)

I completely agree with you, but unfortunately, the columns aren't selectable.  I think they should be and will enter in a product suggestion with NI.  What I have done in the past is what you are suggesting.  I did it with rows instead of columns.  With multilist boxs you can select entire rows (not columns) and that gave the effect I wanted.  Then I would drag and drop and update the Row headings so that they stayed the same.  It is a lot of work and not as easy as it should be, but the result is very rewarding.

Hope this helps!

Dan 

Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 8 of 12
(4,489 Views)
Thanks again Dan!

Your help is much appreciated, and I'm glad to see someone else was thinking in the same direction I was when planning this out. I suppose I'll start working on those subvis now 😉

-mark
0 Kudos
Message 9 of 12
(4,487 Views)
I believe you could use the invoke node on the multicol listbox with Get Clicked Col Hdr to get the index of the column of the header you select and go from there.
0 Kudos
Message 10 of 12
(4,146 Views)