Click here to Skip to main content
15,915,818 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guys. im a newbie programmer

As you can see my code for getting value in the data grid view to list view is stated there. when I click add button, the item of the 2nd cell from the data grid view is going up on the first cell of the list view (which is what I want), and the sub item which is from the 3rd cell of data grid view is going up on the 2nd cell of the listview, BUT!! i goes on the 2nd row and 2nd cell.. I don't know what to do. thanks for helping in advance. :)

VB
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click


        Dim list As New ListViewItem

        If dataGrid2.SelectedRows.Count >= 0 Then

            For Each row As DataGridViewRow In dataGrid2.SelectedRows

                bookList.Items.Add(row.Cells(1).Value.ToString())
                list.SubItems.Add(row.Cells(2).Value.ToString())
                bookList.Items.AddRange(New ListViewItem() {list})


            Next

        Else

            MsgBox("Select a Book!", MsgBoxStyle.Exclamation, "Warning")

        End If


    End Sub
Posted
Updated 21-Oct-12 21:25pm
v2
Comments
Sergey Alexandrovich Kryukov 22-Oct-12 13:57pm    
It it System.Windows.Forms, or something else? Always tag the application type or UI library you use.
--SA

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900