how to transfer datagridview record to listview?

anyone have an idea?

Recommended Answers

All 5 Replies

Get the datagridview records into table or dataset and loopthough the recods and add to list view in loop

yes, but i don't know how to code it...

here's my code

but all i want is to transfer all record from gridview to listview

Listview1.Enabled = True
        Dim item As New ListViewItem
        Dim i, j As Integer

        With item

            i = Listview1.CurrentRow.Index.ToString

            item = lstLicense.Items.Add(DataGridView1.Item(0, i).Value.ToString, 0)
            item.SubItems.Add(DataGridView1.Item(1, i).Value.ToString)
            item.SubItems.Add(DataGridView1.Item(2, i).Value.ToString)
            item.SubItems.Add(DataGridView1.Item(3, i).Value.ToString)

        End With

Try using the for loop.

for i as integer=0 to DataGridView1.rows.count-1
     ' Add your code which adds records to list  

Are you using listbox?

thanks it works ^_^

i have same problem but its not working..because my data gridview is in another form and my listview is in another form..i want if i click button my records in datagrid will be transferd in listview wich is in another for....need some help what is the code for this problem..?Tnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.