简体   繁体   中英

Cycling through selected item in listview and populating another listview from subitem that has comma delimited subitem

I have a listview called lstProducts. The user selects an item in lstProducts to populate various objects in a form. Three of the subitems are comma delimited strings that must be parsed to populate lstAss.

I have code that cycles through but it is not parsing correctly:

Dim input As String = lstProducts.Items(x).SubItems(6).Text
        Dim result As String() = input.Split(New String() {","c}, StringSplitOptions.None)
        Dim m As String
        Dim t As String
        For Each s As String In result
            Dim inputT As String = lstProducts.Items(x).SubItems(10).Text
            Dim resultT As String() = inputT.Split(New String() {","c}, StringSplitOptions.None)
            Dim inputM As String = lstProducts.Items(x).SubItems(11).Text
            Dim resultM As String() = inputM.Split(New String() {","c}, StringSplitOptions.None)
            s = Trim(s)
            For Each t In resultT
                t = Trim(t)
            Next

            For Each m In resultM
                m = Trim(m)
            Next
            Dim li As New ListViewItem()

                li = lstAss.Items.Add(s, 0)
                li.SubItems.Add(t)
                li.SubItems.Add(m)
            Next

To be parsed:

col6: 1,2,3,4 col10: a,b,c.d col11: 96,97,98,99

Desired ouput:

col0
1
2
3
4

col1
a
b
c
d

col2
96
97
98
99

with my code lstAss is currently populating as follows:

col0
1
2
3
4

col1
d
d
d
d

col2
99
99
99
99

How do I get this to parse correctly? I have tried multiple ways to do this and this is as close as I have gotten.

The integrity of the data being fed into lstProducts is guaranteed through error handlers. There is a matching subitem in col6, col10, & col11.

I solved this. I simply combined the 3 subitems into 1 comma delimited string and parsed it back into the originating listview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM