Combobox - Stop (eliminate) Highlight of Item Upon Selection-VBForums
Results 1 to 14 of 14

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

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    681

    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.
    MSDN online for VB6 - Language Reference - Controls Reference
    Download MSDN October 2001: disk 1, 2 and 3

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

    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
    3,421

    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. Please understand that Ive been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a VB6 random code folder that is overflowing. Ive been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

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

    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
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
    3,328

    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
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
    6,361

    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
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
    6,361

    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
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
    6,361

    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
    Addicted Member
    Join Date
    Feb 2017
    Posts
    141

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.