Results 1 to 11 of 11

Thread: [RESOLVED] [2005] ComboBox ForeColor

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Resolved [RESOLVED] [2005] ComboBox ForeColor

    When I set the ForeColor of my ComboBox, ALL of the text turns to that color. Is there a way to set it so that only the text in the TextBox portion of the ComboBox turns to that color, and the rest stays in black text?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] ComboBox ForeColor

    You would have to draw the items yourself if you want to use different text colours. Check out the documentation for the DrawMode property for an explanation and code example.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] ComboBox ForeColor

    Its called OwnerDrawn where you handle all the drawing/painting of the items in the list. You can draw in different colors, fonts, and size for each individule item if you want.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Re: [2005] ComboBox ForeColor

    If confusing you wish to be the speak in cryptic code you must.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] ComboBox ForeColor

    What are you trying to say/ask?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] ComboBox ForeColor

    What's confusing or cryptic about this?
    Check out the documentation for the DrawMode property for an explanation and code example.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] ComboBox ForeColor

    After a quick search, here is an example from msdn online help pages...

    http://msdn2.microsoft.com/en-us/lib....drawmode.aspx
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Re: [2005] ComboBox ForeColor

    Um, I was practicing my If/Then structure? Or maybe not.

    All this stuff seems to come pretty easily for you guys. I assume that it's easy to forget how overwhelming it all can be.

    But I know what to look at now for this. Maybe it can be done.

    I'll give it a try tomorrow.

    How's Australia this time of year? I know a few pedal steel players over there.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Re: [2005] ComboBox ForeColor

    I've been through the code at http://msdn2.microsoft.com/en-us/lib....drawmode.aspx
    Played around with it. Made it do different stuff. But I couldn't make it do what I want. I don't understand it.

    All I want is a ComboBox with these items in these colors.
    "Homework" (black"
    "Test" (red)
    "9 Weeks Test" (blue)
    "Semester Test" (green)

    I see that I can make the choices in the listbox section have their own colors, though I don't understand exactly how it works. And I know that I can set the ForeColor to my color of choice for the TextBox part of the ComboBox. Of course, setting that changes ALL of the text (including the choices) to that color.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] ComboBox ForeColor

    In the example from the link I posted, your link is broken, if you look at the ComboBox1_DrawItem event you can see how it colors the three items in the combo.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Re: [2005] ComboBox ForeColor

    I changed a few things and experimented. Finally got the result I was wanting. Actually, something a little better. Thanks.

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