LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to adjust serial numbers in numeric order when we delete item from multicolumn listbox

Hello , i am using multicolumn listbox to display data having N rows and 6 columns. The 0th column in my multicolumn listbox is of serial numbers. I have added the functionality of adding or removing items from the listbox. I just want that if i remove data from a certain row , then the serial numbers get adjusted in numeric order. For e.g i have data in my multicolumn  listbox with serial numbers as 0,1,2,3,4,5,6. Now , if i delete data of serial number 3 then , i should get 0,1,2,3,4,5 on my multicolumn listbox instead of 0,1,2,4,5,6. Please help me how can i do this?

0 Kudos
Message 1 of 6
(2,652 Views)

Hi shaun,

 

so you just want to re-number the first column in your listbox?

Just do it!

 

- Keep your array data in a shift register.

- iterate over all rows.

- replace the first element of each row by your index number

 

Reminder: When you have problems with your VI you should attach that VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,647 Views)

Well, the items is just a 2D array of strings, so you simply need to sort the entries and write them back.

 

I think there is an openG tool to sort 2D arrays by a certain column, or you can write your own version.

 

Depending on how the numbers are formatted, you might need to do a numeric sort unless they all have the same number of digits (The default sot for strings is alphabetic).

0 Kudos
Message 3 of 6
(2,643 Views)

can u tell me how can i update the items in only the first (0th) column of multicolumn listbox instead of updating all of the columns ?

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

Hi Shaun,

 

use ReplaceArraySubset on your 2D array data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(2,605 Views)

You need to rewrite all items. Assuming you have the 2D array of strings stored in a shift register, you can replace the first column with a new 1D array using "replace array subset". Then write back the listbox items.

 

It would be significantly easier to suggest a solution if you would show us your VI. Please attach it.

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