Vb.net List within a list

161 views Asked by At

So far I have the following code below. How to display each list value to textboxes?

    Dim list As New List(Of String)

    list.Add(dgvData.SelectedCells(0).Value.ToString)
    list.Add(dgvData.SelectedCells(1).Value.ToString)
    list.Add(dgvData.SelectedCells(2).Value.ToString)
    list.Add(dgvData.SelectedCells(4).Value.ToString)

    Dim val As String
    For Each val In list
        ' MsgBox(val)
    Next
1

There are 1 answers

0
Joan On

Add your code in the CellEnter Event. You don't need to declare the list.

Private Sub YourDataGrid_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles YourDataGrid.CellEnter

txtbox1.Text = YourDataGrid.Item(col, row).Value.ToString
txtbox2.Text = YourDataGrid.Item(col, row).Value.ToString
txtbox3.Text = YourDataGrid.Item(col, row).Value.ToString
txtbox4.Text = YourDataGrid.Item(col, row).Value.ToString

end sub