Results 1 to 14 of 14

Thread: Combobox - Stop (eliminate) Highlight of Item Upon Selection

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Title says it all.
    Want to remove the selected item highlight after the user has made their selection.

    Have tried number different ways but only thing seems to work
    is with the user selecting another control.

    Anyway?

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Quote Originally Posted by vb6forever View Post
    Title says it all.
    Want to remove the selected item highlight after the user has made their selection.

    Have tried number different ways but only thing seems to work
    is with the user selecting another control.

    Anyway?
    If the Style is 2 (Dropdown List) it is highlighted not because it has something selected but because it has the focus.
    If the Style is 0 (Dropdown Combo) just set .SelLenght = 0.

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    OR, you can do this in whatever function you want to have the item deselected but still shown:

    Code:
    Dim cboText As String    
    cboText = Combo1.Text
    Combo1.ListIndex = -1  '(if you just did this...then the combobox would be blank showing...so, reset it to what it was
    Combo1.Text = cboText

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

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    I'd be interested in a solution to this one too. Specifically, controlling the BackColor of a selected DropdownList.

    I've managed to do it (with subclassing, and with substantial help credit to Bonnie West) for the ListView. I've spent a few minutes a couple of times in the past to try and do it for the DropdownList, but never gotten it up and running.

    I'll post my ListView code if anyone would like. For the ListView, I specifically wanted it to keep showing the selected item, even when the control lost the focus. In other words, I wanted to have the look of the ListBox.

    Best Regards,
    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.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Well, what I posted works for DD List as well...but as far as changing the BG Color...I'll have to look into that one. My post simply 'unhighlights' the 'selected' item in the combobox, defaulting to the BG color of the original cbobox.

    EDIT---I didn't mean 'changing the BG color'---I know you meant changing the color of the SELECTED item onlyl....like I said, will have to experiment.

    Sammi

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Eduardo and SamOscarBrown:
    Could NOT get either idea to work.
    Attached Files Attached Files
    Last edited by vb6forever; Dec 3rd, 2017 at 09:41 PM.

  7. #7
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Quote Originally Posted by vb6forever View Post
    Eduardo and SamOscarBrown:
    Could NOT get either idea to work.
    Some Events need a decoupling (a "delayed reaction", usually done per Timer):

    Code:
    Option Explicit
    
    Private Sub Form_Load()
      Timer1.Enabled = False: Timer1.Interval = 15
      
      Combo1.AddItem "A"
      Combo1.AddItem "B"
      Combo1.AddItem "C"
      Combo1.ListIndex = 1
    End Sub
     
    Private Sub Combo1_Click()
      Timer1.Enabled = (Combo1.ListIndex >= 0)
    End Sub
    
    Private Sub Timer1_Timer()
      Timer1.Enabled = False 'switch it off again immediately
      If Combo1.Style = 0 Then Combo1.SelStart = 10000: Combo1.SelLength = 0
    End Sub
    HTH

    Olaf

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Thanks Olaf.

    Interesting use of the Timer.
    Thought it would have to be subclassed.
    Sadly, won't work for Style: DropDown List
    Have updated zip file example.

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Try this on your DDL combobox:

    in form_load:

    Code:
     With Combo2      
          .AddItem "A"
          .AddItem "B"
          .AddItem "C"
          .ListIndex = -1
       End With
    Code:
    Private Sub Combo2_Click()   
          Command1.SetFocus
    End Sub
    Is that the desired affect?

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    SamOscarBrown

    Yes that does it.
    Sadly have to get another control involved.

    Thank you, and also a Thank you to Olaf.
    Updated zip to reflect.

    BTW:
    I have several version of the zip (manage attachment) showing and would like to delete all except the last.
    Any idea how to delete them?

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    If you are talking about this Forum attachments, go to Settings (on menu), My Settings, Attachments (on left), you can delete them there.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    SamOscarBrown:

    Thanks found it. Always wondered where they hid it.

    One problem however. In Settings only shows the last one attached (showing).
    However, in the thread number, (Edit Post > Go Advanced), managed attachment list where I originally attached each one (same name but different size zips), it shows all three(3), with no way to delete the two older ones (same name) uploaded.

  13. #13
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    No, don't believe you can do that IN THE THREADS. If you want THAT done, send a note to the Moderators...I believe they can delete those....

    Sammi

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    858

    Re: Combobox - Stop (eliminate) Highlight of Item Upon Selection

    Thanks Sammi for all your assistance.

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