-
This question is similiar to previous question "Getting selection from DBGrid".
I got two form, one form contains the Customer Number and it allows the user to click onto the button to display the second form witch contains the listview. I click onto any onto any column and the selected id is then return and display in the first form.
the following is used - frmPrint!lvwClients.SelectedItem
the problem is when the user rearrange the column order clicking onto the list always returns what ever is in the first column. How could you make it return only the column containing the ID.
Thanks in advance
-
When you first fill the listview, you would have known which column contained the ID you require. Store this Column in a static variable or hard code it and then use this as an index to retreive the correct value like this;
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
MyID = Item.SubItems(staticX)
'Where staticX was the column you originally placed your ID in.
'If ID was the first list item then simply use
MyID = Item
End Sub
This will return the correct value no matter where the column is placed.
-
I always use tag of each listitem to store key.
Dim mitem as listitem
set mitem= listview1.listitems.add(,,Item1")
mitem.tag= Yourkey
-
Thanks
Thanks a lot brothers..
Gee why did'nt I think of that!