Results 1 to 7 of 7

Thread: list view selcted count

  1. #1

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Is there a listView property which returns the number of checked items in a listview list?

    I was going to do it like this but I wondereed if there was already a property.

    (I'm sur I can't find it if there is!)


    Code:
    Dim SelectedCount As Integer
    Dim i as Integer
    
    For i = 1 To ListView1.ListItems.Count
      If ListView1.ListItems(i).Checked Then
        SelectedCount = SelectedCount + 1
      End If
    Next i
    Mark
    -------------------

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    There is indeed a property and it is called "SelCount"

    List1.SelCount
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Is there a listView property which returns the number of checked items in a listview list?
    Mark
    -------------------

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Terribly sorry old chap, crossed wires and all. Thought you were talking about list box.
    Iain, thats with an i by the way!

  5. #5
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Cool

    I don't think there is....

    Previously I've just looped through my ListItems checking the ListItem.Selected boolean and counting them that way...

    Not too big a pain in the arse unless your list is huge..



    Dan

    Ok - for Selected read Checked not that it matters much...

    [Edited by Judd on 04-12-2000 at 08:25 AM]

  6. #6
    Guest
    This is so late! But I found it .

    Code:
    'Author: Ascher Stefan
    'Author's email: http://stefan.scriptmania.com
    'Date Submitted: 11/26/1999
    'Compatibility: VB 6
    
    'Task: SelCount for ListViews. I have not found a property which returns
    the count of the selected Items in a ListView (VB5), but it is no problem
    to make it on your own via API.
    
    'Declarations
    Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA"
    _
       (ByVal hwnd As Long, _
        ByVal Msg As Long, _
        ByVal wParam As Long, _
        lParam As Any) As Long
    Private Const LVM_FIRST = &H1000
    Private Const LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50)
    
    
    'Code:
    Public Function GetSelCount(lvhwnd As Long) As Integer
        GetSelCount = SendMessageAny(lvhwnd, LVM_GETSELECTEDCOUNT, 0&, 0&)
    End Function

  7. #7

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Good grief Matt!
    what made you did this one up?

    I couldn't even remember posting the original question!
    Mark
    -------------------

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