Results 1 to 5 of 5

Thread: ListView Index

  1. #1
    Join Date
    Feb 2004

    Unanswered: ListView Index


    I'm having a small problem with another ListView of mine. I have it set to report mode, and I see all the data correctly, however, I need the user to be able to select an item, edit information in the bottom of the form, and then hit an 'edit' button to edit that record.

    My problem is that the ListView is creating a new index for the set, even though I'm pulling the ID from the recordset and placing it into the first column of the listview.

    To clarify a bit, say my table has IDs 25-30, and I can see them listed in the ListView. When I click on the first item, instead of having an index = that id (which I need), it comes up with ID 1. the next is 2, and so on...

    How do I set the Index of the ListView to be the first column of data (or any column of data)... I know with a combo box all i have to do is use:
    cmbName.ItemData(cmbName.NewIndex) = Recordset!ID.

    Does anyone know the syntax for a ListView? Thanks!
    -Matt H-

  2. #2
    Join Date
    Jan 2005
    in VB.NET, you can setup columns of the listview through the design face.

    To load the data into the Listview:

    With ListView.Items.Add("col1")
    End With

  3. #3
    Join Date
    Feb 2004



    I'm sorry I should've specified though. I need VB6.
    -Matt H-

  4. #4
    Join Date
    Feb 2004
    okay, so I fixed my problem, but here's the newest problem with that listbox.

    I have another listview up top which contains the userID of the user. When selected, I need the Listview on the bottom (with the same info), to use that UserID, and highlight (select) the correct row in the bottom.

    To clarify, here's a mini-graphical representation
    ListView1 - Username, ID, other data...
    form continues with other options

    (after selected something from ListView1, I pull out the SubItem info for UserID - which works) and down below, it needs to select the correct row from

    ListView2 - ID, FirstName, LastName, Etc...

    Any ideas on syntax for SELECTING A ROW based on string? I'm storing the Listview1 UserID in a string.

    -Matt H-

  5. #5
    Join Date
    Aug 2003
    Delft, The Netherlands (EU)
    I guess, you use the Click event of your listbox1.

    To select from ListBox2, use code like

    For i=0 to listbox2.listcount-1
    if listbox2.list(i) = listbox1.text then exit for
    next i

    if i=listbox2.listcount then
    ' not found
    ' do your action here
    end if

    Hope, this helps.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

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