dblk22vball Posted November 26, 2008 Report Share Posted November 26, 2008 I am trying to create a dual listbox xcontrol that will allow you to move an item from listbox to listbox. My intention is to have one listbox have "parts" of the other listbox for configuration purposes. So basically, you select an item in the left hand list box (see vi's), press the right arrow, and the item "moves" over to the righ thand listbox. This is a similiar action to what NI does in the build specifications where you add vis to the startup vi's listbox. I attached my xcontrol, as I cant seem to get any of the items to go anywhere. I am sure I am missing something so very simple. Thanks. Quote Link to comment
jdunham Posted November 26, 2008 Report Share Posted November 26, 2008 QUOTE (dblk22vball @ Nov 25 2008, 11:19 AM) I attached my xcontrol, as I cant seem to get any of the items to go anywhere. I am sure I am missing something so very simple. In the case shown, you are dividing the array into columns, but then you glue it back together with Build Array which makes rows. Things might get better by tossing a transpose array after this, except they won't. A 2D array is not a good data structure. All columns have to be the same size, so you are going to get weirdness with a lot of empty elements being added or truncated on you operations. Why don't you use a cluster of two 1-D arrays, one for each control. http://lavag.org/old_files/monthly_11_2008/post-1764-1227646334.png' target="_blank"> Quote Link to comment
orko Posted November 26, 2008 Report Share Posted November 26, 2008 A common misconception (and a mistake I still make) is to think that by toggling the "Data Change" boolean, you are telling the Xcontrol to execute the "Data Change" event case. The "Data Change" event case only executes when the value terminal is written to by wiring (or using property nodes, or local variables) to the Xcontrol itself on the VI it was placed on. As far as I know, toggling the "Data Change" boolean value in the Action cluster (and someone will correct me if I'm wrong here) will tell LabVIEW to refresh the control values that were loaded inside the Xcontrol. Think of it as a flag for "hey, one of my internal controls has changed it's value." or "Refresh, please." So to make this all work for your application, you would either use local variables to load the two listboxes with their respective values inside each case in which you want to modify them (left/right arrow value change), or perhaps simply move the code that you have in the "Data Change" event case to the "Timeout" case, since that case always executes. I'm no expert when it comes to Xcontrols, but I have had the same problem you had and that is how I was able to get around it. Others may have better suggestions. Quote Link to comment
Jeffrey Habets Posted November 26, 2008 Report Share Posted November 26, 2008 QUOTE (dblk22vball @ Nov 25 2008, 08:19 PM) I attached my xcontrol, as I cant seem to get any of the items to go anywhere. I am sure I am missing something so very simple. You should use the listbox's Value instead of the Active Row property.. The latter one serves a different purpose (setting/getting row specific attributes, also see Ctrl-h when you hover over the property.) I also recommend you use the Value Change events (for both the listbox and booleans) to detect the value change. That's what it's for and I think it's the only way to know for sure you have the correct (updated) value at your disposal. Quote Link to comment
dblk22vball Posted November 26, 2008 Author Report Share Posted November 26, 2008 QUOTE (jdunham @ Nov 25 2008, 02:58 PM) All columns have to be the same size, so you are going to get weirdness with a lot of empty elements being added or truncated on you operations. Why don't you use a cluster of two 1-D arrays, one for each control. DOH :worship: I totally forgot that they have to be the same length..... The cluster idea is working much better (I modified the xcontrol to use that). I just have an issue with getting the correct row that I clicked on, but I should be able to get that. Thanks. QUOTE (Jeffrey Habets @ Nov 25 2008, 03:17 PM) You should use the listbox's Value instead of the Active Row property.. The latter one serves a different purpose (setting/getting row specific attributes, also see Ctrl-h when you hover over the property.) That did help in getting me the right row. For some reason it will not store the correct row though. It always defaults to 0, instead of the selected row. I attached my updated vi's. I tried updating the row in the Data and Display clusters, but it does not seem to be saved for some reason....... Quote Link to comment
Francois Normandin Posted November 26, 2008 Report Share Posted November 26, 2008 Here's a little help. Download File:post-10515-1227650429.zip Quote Link to comment
Jeffrey Habets Posted November 26, 2008 Report Share Posted November 26, 2008 QUOTE (dblk22vball @ Nov 25 2008, 10:40 PM) For some reason it will not store the correct row though. It always defaults to 0, instead of the selected row. I attached my updated vi's.I tried updating the row in the Data and Display clusters, but it does not seem to be saved for some reason....... In your Listbox Value Change you need to tell LV that your state and display data has changed (as you do when you handle the button clicks). To make it even simpler I would simply read the values of the listbox when the buttons are clicked. No reason to save the rows in your state and/or display date in this case. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.