/ Forums / Advansys Formativ / Creating Solutions with Formativ / SelectedItems – Listview

  • Creator
    Topic
  • #4291
    sfritz
    Participant

    I have a listview with multi select enabled, I am able to successfully loop thru but instead of just getting the items selected I am
    getting the same row multiple times. Can you please comment on the code I am providing you as to where my mistake may be? I have been researching and had hoped that the selectedItems would a property I could use but I get a syntax error. Anyway, talk to you soon and the coding examples I have tried are shown below:

    for I = 0 to CDIP_FRM.ListView.SelectedItems.count -1
    iGuideline_area = iGuideline_area & CDIP_FRM.ListView.selected.Caption
    iGuideline = CDIP_FRM.ListView.selected.SubItems.Strings(1)
    iGuideline_num = CDIP_FRM.ListView.selected.SubItems.Strings(0)
    next

    for I = 0 to CDIP_FRM.ListView.Items.count -1
    iGuideline_area = iGuideline_area & CDIP_FRM.ListView.selected.Caption
    iGuideline = CDIP_FRM.ListView.selected.SubItems.Strings(1)
    iGuideline_num = CDIP_FRM.ListView.selected.SubItems.Strings(0)
    next

  • Author
    Replies
  • #7747
    Support 1
    Participant

    The online Help file entry on TListView does not indicate that there is a property like SelectedItems. This is true also for TRzListView.

    Here is a simple example which tests the ListItem property Selected in order to extract your guideline data from multiple selected items (assume MultiSelect = True) and displays them in a message box:

      '-------------------------------------------------------------------------------
      dim I
      dim iArea, iGuideline, iNum
      dim iText
    
      with CDIP_FRM.ListView.Items
        iText = "Selected Items:" & vbNewLine
        for I = 0 to .Count - 1
          if .Item(I).Selected then
            iArea = .Item(I).Caption
            iGuideline = .Item(I).SubItems(1)
            iNum = .Item(I).SubItems(0)
    
            iText = iText & vbNewLine & iNum & vbTab & iArea & vbTab & iGuideline
          end if
        next
      end with
    
      msgbox iText
      '-------------------------------------------------------------------------------
    

    I hope this helps.

    Regards,
    Advansys Support

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.