LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UI to allow arbitrary rearrangement of a 1-D Array of clusters

Solved!
Go to solution

Hi All,

 

Hopefully I can ask this question clearly without a code example, because I would like to keep the discussion as general as possible, so here goes:

 

I have a 1-D array of clusters.  Each element represents a configuration for a whole bunch of attached hardware, and a duration to stay in that state, and a string control so the user can name each step.  I intend to loop through the array to execute a pre-defined series of tasks.

 

I want to have a button on the front panel next to the array called "Rearrange" that launches a dialog box that lists the sting control from each array element, in order, and allows the user to rearrange the order by click/dragging the elements up or down on the list, and when the user clicks OK, it rearranges the array to match the new order.

 

If that wasn't clear, let me state it like this: When you are editing a block diagram and want to rearrange a case structure, you can right click it and select "Rearrange Cases..."  I want that functionality for a 1-D array of clusters.

 

I have absolutely zero clue on how to get moving on this.

Thanks

Matt

0 Kudos
Message 1 of 6
(3,025 Views)

What you ask for can certainly be done, as you can trap mouse events to handle the drag and drop. On a regular Windows app you can use the Windows API to do this as well, though I don't know how well that will translate to LabVIEW seeing as you have to deal with Windows messages. If you Google you may be able to find a control that includes this functionality.

 

What I've always done is to provide a "Move Up" and "Move Down" button to move the selected item in the listbox. Simple.

0 Kudos
Message 2 of 6
(3,014 Views)
Solution
Accepted by topic author Munson1027

The functionality you want is available in the listbox, just configure it to allow dragging and dropping, no dragging outside control, and move only.  Here is an example that gets the cluster names, waits for you to drag things around and click ok, then rearranges.  The event structure is there in case you want move up/down buttons.  I tend to pilfer those buttons from the icon editor.

 

ClusterRearrange.png

 

 

Message 3 of 6
(3,009 Views)

Darin,

 

This works great, thanks.

 

I never understood variants before, and this was the perfect example to help me (finally) understand!  I modified it a bit because I anticipate having certain cluster names repeated, but the associated clusters not necessarily being identical (the cluster contains action AND duration data). I concatenated the name and duration fields and used that as the variant names, and switched to a multi-column list box so that I can see both name and duration (as separate entities in the same row, not a concatenated string).

 

The one thing is that I don't really understand your comment:

 

"For type only use Typedef constant if you have it.  If not, why not?"

 

Are you saying that in place of the index array function I should just have an empty array constant there?  Is that what you mean by a Typedef Constant?

 

Thanks

Matt

0 Kudos
Message 4 of 6
(2,995 Views)

 

 

The one thing is that I don't really understand your comment:

 

"For type only use Typedef constant if you have it.  If not, why not?"

 

Are you saying that in place of the index array function I should just have an empty array constant there?  Is that what you mean by a Typedef Constant?


I prefer to Type Def the element, so I would have a constant cluster there.  I don't include Type Def's in snippets that is why I strung the wire over and used Index Array to get the cluster type.  It doesn't *have* to be a type def'd constant, but it can be a real pain otherwise.

 

0 Kudos
Message 5 of 6
(2,990 Views)

@Darin.K wrote:

The functionality you want is available in the listbox, just configure it to allow dragging and dropping, no dragging outside control, and move only. 


 

Completely forgot about this possibility.

 


@Munson1027 wrote:
I never understood variants before, and this was the perfect example to help me (finally) understand!  I modified it a bit because I anticipate having certain cluster names repeated, but the associated clusters not

Darren had posted a nugget on variants some time ago: http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-10-09-2006/m-p/425269

 

0 Kudos
Message 6 of 6
(2,983 Views)