Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    double clcik to delete.. (2000-sr1)

    i have a list of value in list box... is possible to delete one item from the list box with a double click of mouse?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: double clcik to delete.. (2000-sr1)

    Does the list box have a range of cells as a row source? If so, do you want to delete the cell corresponding to the double-clicked item?
    Or is the list box filled using AddItem?

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: double clcik to delete.. (2000-sr1)

    sorry for my english
    this "Or is the list box filled using AddItem" into a userform.
    Tks.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: double clcik to delete.. (2000-sr1)

    Say that your listbox is named ListBox1. The following code in the userform module will delete the double-clicked item:

    Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    With Me.ListBox1
    If .ListIndex > -1 Then
    .RemoveItem .ListIndex
    End If
    End With
    End Sub

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: double clcik to delete.. (2000-sr1)

    perfect!

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: double clcik to delete.. (2000-sr1)

    Hans...
    But wath is the diffrence for your an this code:
    Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    ListBox2.RemoveItem (ListBox2.ListIndex)
    End Sub

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: double clcik to delete.. (2000-sr1)

    1) I used ListBox1 as name, the other code ListBox2 <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    2) I used a With ... End With block to avoid repeating the name of the list box.

    3) I added a test to avoid the error that would occur when the user has deleted all items and double clicks the empty list box.

    Otherwise, the code is equivalent.

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: double clcik to delete.. (2000-sr1)

    .... after this explain i use your code, naturally!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •