Results 1 to 6 of 6

Thread: [RESOLVED] ListView ..... CheckBoxes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    Resolved [RESOLVED] ListView ..... CheckBoxes



    I used a ListView (view=lvwReport) with CheckBoxes which allow multi-selection. Then I need to know how to detect which rows were selected by the user ?

    Thank you in advance.

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: ListView ..... CheckBoxes

    try this:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim i%, rowCount$
    3.  
    4.     For i = 1 To ListView1.ListItems.count
    5.         If ListView1.ListItems.Item(i).Checked = True Then
    6.             rowCount = rowCount & CStr(ListView1.ListItems.Item(i).Index) & " "
    7.         End If
    8.     Next
    9.    
    10.     MsgBox "Rows " & rowCount & " are checked"
    11.    
    12. End Sub
    13.  
    14. Private Sub Form_Load()
    15.  
    16.     ListView1.ListItems.Add 1, , "Item 1"
    17.     ListView1.ListItems.Add 2, , "Item 2"
    18.     ListView1.ListItems.Add 3, , "Item 3"
    19.  
    20. End Sub
    Harsh
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    Re: ListView ..... CheckBoxes

    Harsh,

    It worked in my project, thank you very much.

    But can you tell what is the difference between "Listview1.ListItem." and "Listview1.ListItems." ?

  4. #4

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: ListView ..... CheckBoxes

    Quote Originally Posted by JohnAtom
    But can you tell what is the difference between "Listview1.ListItem." and "Listview1.ListItems." ?
    are you sure you are getting something like ListView1.Listitem. (without s), because here on my pc, it is only showing ListView1.ListItems.

    BTW, i am using VB 6 SP 6 on win 98. probably again something difference working on 98 and NT based?? :/

    please do post if or not i am wrong.

    thank you
    Show Appreciation. Rate Posts.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    74

    Re: ListView ..... CheckBoxes

    Harsh,

    I develop my project using VB6 SP6 in a XP machine, there are Listitem and Listitems.

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