Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box colored items

Status
Not open for further replies.

QkE

Technical User
Feb 13, 2002
4
NL
Is it possible to give every item in a combo box its own color? So when you click on it to select an item you see multiple colors.

TNX
 
I have a messy solution that doesn't require you to load an ActiveX custom control. Why not create a form with with the appropriate colors and corresponding labels and use it as a subform?
Here's how it works:
1. Create a form called colordropdown.
2. Create a label for each color choice.
3. Create a rectangle object filled with color corresponding to its label.
4. Create a text box called colorchoice and make it small (not hidden).
5. Set the onclick event for each of the labels and rectangles to pass the appropriate value to the colorchoice textbox.

Option Compare Database
Option Explicit
Dim MyName As String

Sub BlackLabel_Click()
myname = "Black"
colorchoice.value = myname
End Sub

6. Set the the following Form Properties:
Default View: Single Form
Views: Allowed Form
Scroll Bars: Vertical Only
Record Selectors: No
Navigation Buttons: No
Dividing Lines: No
Auto Resize: No
Auto Center: No
Border Style: Dialog
Min Max Buttons: None
6. Place the colordropdown form in your main form as a subform.
7. Set the Visible property of the subform to False.
8. On your Parent form, create a Textbox called ColorResult.
9. Set its default value to the appropriate value (auto for example).
10. Set the On Exit event of the subform to pass the value of ColorChoice to ColorResult.
11. Set the On Update event of the ColorResult to move the focus to ColorResult and hide the subform.
12. Draw a Rectangle on your Parent form next to the ColorResult Textbox and embed a down arrow paint object.
13. Set the On Click event of the rectangle to show/hide the subform.

I know that this is a great big mess, but I got it to work for me at work. I needed to be able to do the same thing, but system admin forbade me to download any custom activex controls so I had to create my own. Hopefully, someone can propose a better one than this for you.

Best of luck
CorporateTrainer


 
TNX for the reply. I tried it and it works perfectly. Very nice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top