Results 1 to 9 of 9

Thread: Double Clicking List Items

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Double Clicking List Items

    Can you make say a msgbox pop up when 1 item in a list is double clicked?

    Thanks

  2. #2
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Double Clicking List Items

    VB Code:
    1. Private Sub List1_DblClick()
    2. msgbox "MESSAGE TO POP UP"
    3. End Sub
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Double Clicking List Items

    You may want to time the clicks, but this is the basics.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. List1.AddItem 1
    5. List1.AddItem 2
    6.  
    7. End Sub
    8.  
    9. Private Sub List1_Click()
    10. Static clcount
    11. clcount = (clcount + 1)
    12. If clcount = 2 Then Msgbox "Double-Clicked!" : clcount = 0
    13. End Sub

  4. #4
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Double Clicking List Items

    You may want to time the clicks, but this is the basics.


    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. List1.AddItem 1
    5. List1.AddItem 2
    6.  
    7. End Sub
    8.  
    9. Private Sub List1_Click()
    10. Static clcount
    11. clcount = (clcount + 1)
    12. If clcount = 2 Then Msgbox "Double-Clicked!" : clcount = 0
    13. End Sub
    ummm... why do it this complicated? whats wrong with the double click event?
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Double Clicking List Items

    The list data is text and also i want the message box to be different for each list item.. thanks :P

    @Arachnid13, im not trying to make it so when someone double clicks the list a message box appears, i want it so when they click a single item (i.e not the whole list) the message box appears.

    Cheers
    Last edited by BefunMunkToloGen; Apr 6th, 2005 at 05:11 PM.

  6. #6
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Double Clicking List Items

    VB Code:
    1. Private Sub List1_DblClick()
    2.  Msgbox List1.List(List1.Listindex)
    3. End Sub

    casey.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Double Clicking List Items

    That works fine, but I want it like this (sorry its late here lol).

    On double clicking 1234 it says "Hello"
    On double clicking item4 it says "tralala"

    1234 and item4 are different items if you know what i mean.

  8. #8
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Double Clicking List Items

    if you want different for each one then you may have to do a select case
    VB Code:
    1. Select Case List1.List(List1.Listindex)
    2.  Case "1234"
    3.    msgbox "Hello"
    4.  Case "something else"
    5.    msgbox "tralala"
    6. End Select
    if you have a lot of different items then it may be better to put all the answers in a array then call the array like this
    VB Code:
    1. Private Sub List1_DblClick()
    2.  Msgbox thearray(List1.Listindex)
    3. End Sub

    casey.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Double Clicking List Items

    What would i do without you? lol thanks al lot casey and everyone else

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