Consulting

Results 1 to 14 of 14

Thread: Seletion problem in listbox (Userform)

  1. #1
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location

    Seletion problem in listbox (Userform)

    Hi,
    I have included an example of a listbox of which the MultiSelect property is set to fmMultiSelectMulti.
    However when using the textbox (to search) the MultiSelect property temporary changes to fmMultiSelectMulti
    in order to show all possible answers. But this methode causes a selection problem. Who knows how to solve this?

    regards,
    Stranno
    Attached Files Attached Files

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    MultiSelect property is set to fmMultiSelectMulti. ...
    (Then) the MultiSelect property temporary changes to fmMultiSelectMulti
    Is that a Typo?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    Sorry. Yes it's a typo. The first MultiSelectMulti should have been MultiSelectSingle.

  4. #4
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    I see there's a typo in the title as well. Seletion must be selection of course.

  5. #5
    snb
    Guest
    I'd prefer to use doubleclick in the combobox or the listbox1 to add an item to listbox2.
    Attached Files Attached Files

  6. #6
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    Yes, but In my project there are 10 listboxes to drag to. It depends on what the user wants to do with the dragged item.

  7. #7
    snb
    Guest
    Strictly speaking you don't need that listbox1 at all.
    Attached Files Attached Files

  8. #8
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    In that case i prefer this solution because the search method is more suitable for my project.
    The user, for example, looks for an item which contains the partial string "huur". Like in:
    netto huur
    huur incl btw
    maximale huur
    etc.
    And this can't be achieved with the MatchEntry of a ComboBox.
    But drag end drop is no option the way i'd like to do it?

    In other words, isn't it possible to select one item in a multiple selection?
    Perhaps in combination with the Shift key down?
    Attached Files Attached Files

  9. #9
    snb
    Guest
    The information you provide is as volatile as your requirements.

  10. #10
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    I think i found a solution.

    Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Dim MyDataObject As DataObject
    Dim Effect As Integer
    On Error Resume Next
    If Button = 1 Then
    Set MyDataObject = New DataObject
    If Len(Trim(ListBox1.List(ListBox1.ListIndex))) <> 0 Then
    MyDataObject.SetText ListBox1.List(ListBox1.ListIndex)
    Effect = MyDataObject.StartDrag
    Set MyDataObject = Nothing
    End If
    End If
    On Error GoTo 0
    End Sub

    I Changed ListBox1.value into ListBox1.List (Listbox1.ListIndex). And this seems to work.

    Snb, I understand your remark partly. But you can't say that i have changed the subject.
    I did have difficulties to select a single item in a multiselection within a ListBox.


    Sometimes it makes sense to approach a problem from a different direction. Providing alternative ways to solve problems
    is what you do sometimes. And i really appreciate that. But don't "accuse" me from volatility. Ok, i gave up names instead
    of the real items (for privacy reasons) , but the principle remained the same. I wanted to drag and drop an item from one
    ListBox to another with the means i provided (the TextBox and the ListBoxes).

  11. #11
    snb
    Guest
    You are on my ignore list now.

  12. #12
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    I regret that because you are a great VBA programmer, and you've helped me several times. The thing is that helping lesser gods like myself is not a competition. And i can not help feeling that you consider it as such so now and then. Anyway, thanks for your help.

  13. #13
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    I believe that you have to write your own custom DragAndDrop Method.

    Here on VBAX:
    Solved: Drag and Drop within VBA

    At MSDN
    Performing Drag-and-Drop Operations in Windows Forms

    Accomplishing drag-and-drop operations within Windows applications is done via the handling of a series of events, most notably the DragEnter, DragLeave, and DragDrop ...
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  14. #14
    VBAX Tutor
    Joined
    Jun 2005
    Posts
    214
    Location
    Thanks SamT but i've found a solution for my problem (#10). This worked for me.

Posting Permissions

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