LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete row in listbox with formatting

Hello, I have a listbox and I want to delete selected rows (by clicking button in the example). It deletes the rows just fine but the problem is that I also want to preserve formating of the items when they are moved. The only way is to copy the formating programatically which is incredibly s  l  o  w. Even if I defer panel updates it takes second to delete 20rows and reformat the rest. Do u have anybody any idea how to do that in more usable way? Thanks!!!
Message Edited by ceties on 07-17-2009 06:44 AM
LV 2011, Win7
0 Kudos
Message 1 of 13
(4,303 Views)
Wow that is slow. I don't know of a better way other than with nodes like you've done, but try putting the write node outside of the main For loop like I've done on the attached picture. This is faster.
Richard






Message 2 of 13
(4,289 Views)
Thanks a lot. I overlooked that possibility. But still to delete and reformat first 100 rows of 1000 takes more than 10secs at my computer.
LV 2011, Win7
0 Kudos
Message 3 of 13
(4,276 Views)

On my computer, the modified version of the VI, with 1000 created lines (rather then 100), is taking about 1 second.

The unmodified version takes about 8 to 10 seconds.

Richard






0 Kudos
Message 4 of 13
(4,258 Views)
I am erasing first 100 rows of 1000 - that takes more than 10sec.
Message Edited by ceties on 07-17-2009 09:07 AM
LV 2011, Win7
0 Kudos
Message 5 of 13
(4,252 Views)
Did something changed in LV2009 or does the problem remain? Thanks
LV 2011, Win7
0 Kudos
Message 6 of 13
(4,142 Views)
One of the big reasons your code is so slow is because of the way you are updating the formatting.  For every cell you select, you run 2 times (number of rows) loop iterations to get or set the formatting.  I would store all the row formatting in memory in arrays and delete the proper rows, then run one loop that sets all the formatting.  That way you only have to run a loop (number of rows) times and set the new formatting.  You can also you Defer Panel Updates to help with some speed as well.
Message 7 of 13
(4,139 Views)

Hi Ceties,

 

Matthew is 100% right.

 

If you "calculate" formatting in memory, and you will update everythink at once, you can incredibly increase performance. While with your code, it took me about 53 seconds to "delete" everythink, with little modification time necessary to perform this operation dropped downd to about 100ms!

 

 

 Multicolumn Listbox Formatting.JPG

 

To be trully honest, I didn't test this program completely, bu I hope it has the same  functionality as the one you provided 😉

 

 

Regards,

Martin

Certified-LabVIEW-Developer_rgb.jpg

Message 8 of 13
(4,118 Views)

Thank you both. I followed your advice. The previous example assumed that the whole row has the same formating. I altered the code to respect different formating for each cell. Even with defering panel updates I am not able to get better results than 1sec on my machine- ERASING ONE ROW.

The last I can think of is keeping the formating in memory the whole time which I don't wanna do since I update the Listbox from different loops. Maybe Action engine might work for that but before I wante to ask if there is still some space fore the code improvement.

  

Thanks

Message Edited by ceties on 09-21-2009 11:19 AM
LV 2011, Win7
0 Kudos
Message 9 of 13
(4,073 Views)

Hi Ceties,

 

You are right that deffering front panel in this case doesn't help so much.  This is because Multiconumn Listbox doesn't use Synchronous Display by default. If you set to use synchronous display, and you wouldn't deffer front panel updates, your performance would be significantly wors. 

 

With attached example, to erase one row, when I set different formatting for each cell, it takes about 0.6s on my computer to finish. With Synchronous Display it takes more than 6s !, so you could see great difference. Moreover,as you can see, I read all the time actual formatting. this reading takes about 0.20s itself. If you avoid reading it all the time, and instead you will keep it in memory, you can save somethink like 30% of the time!

 

 

In case you need to update each cell font separately,  you need to update a lot of cells. In our case it is about 2000 property node calls. Positive think is, that more cells you delete, faster theoperation is 😄

 

Anyway, I belive that it is not very important to keep all the data in the table. If the performance is of the question, I would keep all data in memory in shift registers for example, and I would all the time display just reasonable amount of data in listbox. You can implement scrolling by your self, and thus you could keep just couple of hundred rows displayed.However, this would give another challange to update all the time formatting as you scroll 🙂

 

 

 

At the last, I believe that with good architecture it should not be problem to update those data in table from different locations. It can just take some more time to develop your code Smiley Sad 

 

 

 

Use just useful advices 🙂

Martin

Certified-LabVIEW-Developer_rgb.jpg

Message 10 of 13
(4,046 Views)