CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    Israel
    Posts
    396

    Question VB6 - ListBox with CheckBox Style?

    Hi
    I use the ListBox with the CheckBox style in my form.
    The problem is that if the user want to mark one item he need to double click on the item and not one click.
    Any one ca tell me how to get it done with one click?
    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    try one of these 2:

    Code:
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
        Item.Checked = Not Item.Checked
    End Sub
    
    Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        ListView1.HitTest(x, y).Checked = Not ListView1.HitTest(x, y).Checked
    End Sub

  3. #3
    Join Date
    Sep 2002
    Location
    Israel
    Posts
    396
    Hi
    This is .Net i ask about VB 6.
    Thanks.

  4. #4
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    nope, this is vb6, not .NET.....

  5. #5
    Join Date
    Sep 2002
    Location
    Israel
    Posts
    396
    OK
    I cant find this events, but i see that you write ListView- i use ListBox.

    The ListBox don't have the HitTest function and ItemClick event with the argument that you wrote.

  6. #6
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    Many apologies - listbox, not listview!

    I find the listbox control a pain in the a*se. See the following code, it should be sufficient...

    Code:
    Option Explicit
    
    Private mblnLoading As Boolean
    Private mblnBusy    As Boolean
    
    Private Sub Form_Load()
    
        Dim X As Integer
    
        mblnLoading = True
    
        For X = 0 To 9
        
            With List1
            
                .AddItem Screen.Fonts(X)
                .Selected(X) = True
            
            End With
        
        Next ' x
        
        mblnLoading = False
        
    End Sub
    
    Private Sub List1_ItemCheck(Item As Integer)
        
        If mblnLoading = False And mblnBusy = False Then
    
            List1.Selected(Item) = Not List1.Selected(Item)
    
        End If
    
    End Sub
    
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        mblnBusy = True
    
            List1.Selected(List1.ListIndex) = Not List1.Selected(List1.ListIndex)
    
        mblnBusy = False
        
    End Sub

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

Featured