04-04-2011 12:15 PM
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
Solved! Go to Solution.
04-04-2011 12:40 PM
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.
04-04-2011 01:06 PM
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.
04-04-2011 02:39 PM
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
04-04-2011 02:48 PM
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.
04-04-2011 03:06 PM
@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