Question getting data from a listView

Roofuss

Member
Joined
Apr 19, 2009
Messages
9
Programming Experience
Beginner
Hi i currently have a listview on my form that is set to "details" view and is popoulated by a table in my sql database.

what i want to be able to do is when i double click on a selected row i want all the details in that row to appear in another form so that i can edit them.

how do i populate the edit form with the data from the selected row i am double clicking on?

can anyone help me?

Thanks Roofuss
 
I'd suggest: on the second form You may place some textbox controls (with "ReadOnly" property set to false"), their count corresponds to number of colums of Your Listview. Let's say the name of those controls are Text1, Text2 an so on.
Then, to the first form, witch contains Listview control, You must add a sub that handles the double_click event of listview:

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick

'Inside this sub you put the code for reading the selected item's text and item's subitems texts, smth like this:
Form2.Text1.Text=Me.ListView1.SelectedItems(0).Text
Form2.Text2.Text=Me.ListView1.SelectedItems(0).SubItems(0).Text
'an so on.
 
Back
Top