Results 1 to 3 of 3

Thread: Finding (*and selecting*) a listview

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Dublin, IRE
    Posts
    111

    Unhappy

    I've set up a listview in my project, and a command button which opens a seperate form with a "find" box on it.

    When the user clicks the "find now" button on the second form, I do a FINDFIRST on the recordset of the listview control, and now I want to close this window and highlight the "found" record on the listview.

    I tried setting the key of each list subitem when I was adding them by

    sCurJob = Format(CStr(myRs!jobid), "000000")
    Set itmX = ListView1.ListItems.Add(n, sCurJob, sCurJob)

    and then just use

    Set frmAllList.ListView1.SelectedItem = _
    frmAllList.ListView1.ListItems(sNum)

    where sNum is the "jobid" field of the found record, but I keep getting "Invalid Key" on the Add method.

    Scrapping this (temporarily), I tried the .FindItem method, but this only seems to work satisfactorily for the main item, and not the subitems, even though I set the 'value setting' to 1 (for lvwSubitem).

    Has anybody any experience of this kind of thing, and how did they handle it? (Better than these clumsy tries, I bet!)

    Ta.

  2. #2
    Member
    Join Date
    May 2000
    Posts
    63
    In your code, instead of using the line

    Set frmAllList.ListView1.SelectedItem = _
    frmAllList.ListView1.ListItems(sNum)

    try using

    frmAllList.ListView1.ListItems(sNum).Selected = True


  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Dublin, IRE
    Posts
    111

    Angry

    Tried that. Apparently, it's an "invalid use of property".

    In the meantime, I retried the old "FindItem" method of the listview. It works like a charm for the text value, but VB only allows full word searches on subitems. Even the example given (which needs a lot of work - who the hell writes these examples) doesn't work properly.

    Having to type in the entire text doesn't strike me as very useful.

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