Results 1 to 12 of 12

Thread: [RESOLVED] Add more than one item to Combo.Text

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2015
    Posts
    918

    Resolved [RESOLVED] Add more than one item to Combo.Text

    Hello VbForums
    When we click an item in a combobox, only one seleccted item is displayed in the combo text.
    I want to display 3 items.
    I created an invisible textbox but it didn't work.
    Code:
    Private Sub Combo1_Click()
    n = n + 1
     Select Case n
          Case 1
            Text1= Text1 + Combo1.Text
     Case 2
            Text1 = Text1 + "    " & Combo1.Text
           Case 3
            Text1 = Text1 + "    " & Combo1.Text
        End Select
     Combo1.text = Text1 .Text
    End Sub
    In Text1_Change event, I tried this but without success.
    Code:
    Private Sub Text1_Change()
    Combo1.text = Text1 .Text
    End Sub
    Thanks

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,422

    Re: Add more than one item to Combo.Text

    There is no Multiselecting in a Combobox. Period!
    AFAIK, you cannot set the textbox-part to multiline (except there is an API-hack!),
    you cannot set the height of the textbox-Part to anything different except with FontSize.

    If you need multiselect, then a Listbox is your friend.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2015
    Posts
    918

    Re: Add more than one item to Combo.Text

    Quote Originally Posted by Zvoni View Post
    There is no Multiselecting in a Combobox. Period!
    AFAIK, you cannot set the textbox-part to multiline (except there is an API-hack!),
    you cannot set the height of the textbox-Part to anything different except with FontSize.

    If you need multiselect, then a Listbox is your friend.
    Perhaps I was not clear enough.
    I'm not looking for a multi selecting of items.
    Each time I click an item, I want it to be displyed in the combo text without deleting the existing one.
    I want to reproduce the conntent of the textbox in the combobox.
    thanks

  4. #4
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: Add more than one item to Combo.Text

    you can used textbox and listbox control to replace combox control

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: Add more than one item to Combo.Text

    I've got a multi-select ComboBox. I've used it for years. It could use some work, as I'm not totally happy with it, but it does get the job done. Hold on and I'll post it.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: Add more than one item to Combo.Text

    Okay, here's a little demo (attached). I haven't looked at that code in the ComboCheck.ctl in a very long time, but it's a piece of code that's used everyday and is extremely well exercised. Again, it could probably use improvements, but it certainly gets a job done for me that's needed.

    Name:  ComboCheck.jpg
Views: 294
Size:  13.7 KB

    Enjoy,
    Elroy
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2015
    Posts
    918

    Re: Add more than one item to Combo.Text

    Elroy
    Million thanks
    this is what I'm looking for.

  8. #8

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: [RESOLVED] Add more than one item to Combo.Text

    Interesting. It looks like a nicer implementation than mine.

    Say wqweto, I suspect PGBSoft saw this thread and decided to post it. It looks "wrapped up" enough that I'm guessing, once-upon-a-time, PGBSoft tried to sell it, but has long given up on that, and is now offering it as open-source. But that's just my guess.

    It's a nice enough implementation though that I might consider replacing mine with it. He's done a good job of eliminating the pulldown flicker that mine has, and I like the clean checkboxes.

    These forums truly are amazing at times. Ask and ye shall receive.

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,121

    Re: [RESOLVED] Add more than one item to Combo.Text

    It looks recently implemented. From Change_Log.txt
    Code:
       CheckBoxCombo 1.1 (30-06-2018)
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~		
     • Syntax changes of AddItem, RemoveItem and FindItem methods
     • DelimiterConact Property introduced
     • CBCUPdate Property introduced
     • CBCUpdateCompleted event introduced
     • Change event in v1.0 changed to ItemCheck
     • Several bug fixed and optimizations done
     • User Documentation updated
    
     CheckBoxCombo 1.0 (26-06-2018)
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     The initial version of CheckBoxCombo
    Probably needs a bit of more testing in the wild even.

    cheers,
    </wqw>

  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: [RESOLVED] Add more than one item to Combo.Text

    Yeah, I was studying the code. It looks like he's been developing this thing for a while. I was excited, but then I saw all the non-ComCtl32 style subclassing going on in it. It's monitoring for a great many message types.

    Also, there's a tremendous amount of On Error Resume Next (and without being closed with On Error Goto 0) in it.

    Also, I didn't study in great detail but the Property Let Text procedure is commented out. That would be a big handicap for me that would need to be resolved.

    Say PGBSoft, if you're listening, could you give us a bit more information about how much this thing has been used? And, why are you leaning so heavily on On Error Resume Next, and why the Property Let Text procedure isn't available?

    Take Care,
    Elroy

    EDIT1: Truth be told, this thing looks like an F15 fighter, and makes mine look like a P51. However, truth be told, an F15 may shoot down a P51 pretty quickly, but left to its own devices, the P51 was a phenomenally robust airplane (especially with the Rolls Royce Merlin engine in it).
    Last edited by Elroy; Jun 30th, 2018 at 10:39 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12
    Addicted Member
    Join Date
    Jun 2018
    Posts
    189

    Re: [RESOLVED] Add more than one item to Combo.Text

    Elroy,

    Thank you for the quick code review.

    If you are referring to “On Error Resume Next” statements in property settings, yes, most of them should not be. I simply put them at one stage of the development for a particular testing; hence they need to be cleared. Anyway, I will update the code. Thanks for pointing out it, which I had missed.

    For your question about Text property setting, the property is not purposely allowed to set, since it is considered to be a read-only property. The reason is simply integrity purpose, because, the user is only allowed to select items from the list, where the selection is updated as the Text. If it is allowed to set this Text externally, it is going to be a problem. Simply, imagine a Dropdown list style of a regular ComboBox; its Text property setting is read-only when the Text to be set is not in the list. However, you can still set the Text here via the DefaultText property, but that is for a different purpose.

    I have very recently started developing this control and it is still in testing.

    Happy coding!!!
    ____________________________
    PGBSoft

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