I am using Visual Basic 2008. I have a ListView and a DataGridView which have both 3 columns like ProductCode, ProductName & ProductPrice. Now I want to pass ListView values to DataGridView in the same sequence. I want that when I double click on any row in the ListView these row values inserted to DataGridView.
Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
If Not ListView1.SelectedItems.Count = 0 Then
'// check if item is selected.
With ListView1.SelectedItems(0)
Dim lvItem() As String = {.Text, .SubItems(1).Text, .SubItems(2).Text}
'// get ListView selectedItem.
DataGridView1.Rows.Add(lvItem) '// add it to DataGridView.
End With
End If
End Sub