Filling Multiple TextBoxes with ListView Data

时间:2018-09-18 20:02:02

标签: vb.net winforms listview textbox

My script has 20 text boxes for a maximum of 10 Listview Items. There is only one sub-item for each item. My goal is to have these text boxes auto fill for each item added to the ListView.

Example of the textboxes:

1]

Currently, the script bellow has two for-loop statements. The first one will click through all the items in the listview. The second for will input the values to the text boxes. I'm unsure how to incorporate a way to have the script fill all the text boxes. I imagine a case statement will be used.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    For I As Integer = 0 To ListView1.Items.Count - 1

        ListView1.Items(I).Selected = True
        For Each item As ListViewItem In ListView1.SelectedItems

            OpenModule.TextBox1.Text = item.Text
            OpenModule.TextBox2.Text = item.SubItems(1).Text

        Next

    Next

End Sub

Any help or ideas is appreciated.

1 个答案:

答案 0 :(得分:0)

这是对我设法创建的问题的有效答复。请记住,填充文本框的顺序与我的问题无关。我确信可以以某种方式缩短此代码,如果完成,我会将响应标记为已解决;在那之前,这是一个可行的选择。

public EitherAsync<Exception, int> Method() =>
    from a in RightAsync<Exception, int>(Task.FromResult(1))
    from b in RightAsync<Exception, int>(Task.FromResult(2))
    from c in RightAsync<Exception, int>(Task.FromResult(3))
    select a + b + c;