Results 1 to 4 of 4

Thread: listview selection

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Melbourne Australia
    Posts
    4

    Question

    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



  2. #2
    Member
    Join Date
    Jun 2000
    Location
    Perth Western Australia
    Posts
    41

    Talking

    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.

  3. #3
    Guest
    I always use tag of each listitem to store key.
    Dim mitem as listitem
    set mitem= listview1.listitems.add(,,Item1")
    mitem.tag= Yourkey

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Melbourne Australia
    Posts
    4

    Thumbs up Thanks

    Thanks a lot brothers..

    Gee why did'nt I think of that!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width