Solved

Using colors in ComboBox

Posted on 2004-10-20
5
599 Views
Last Modified: 2013-12-26
I am making a program that displays the value of a resistor when the user enters the colors labeled on the resistor.  I want to use a combobox to allow the user to dropdown the different colors that appear on a resistor and select the appropriate color.  However, i want only the colors to display, not the word "green, Yellow,ect."  Or the color and the text would work.  

how do i select different colors in a combobox??

i have tried ComboBox1.Items.Add(Color.Black), and VB accepts this, but when running the program, it doesn't work properly

thanks
0
Comment
Question by:ssalem33
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 12366501
The VB combobox cannot do this.

vbAccelerator.com has a control written in VB6 which is a combobox with added features - one of which is a color picker.
http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/Owner_Draw_Combo_and_List_Box/article.asp

To try it out, download and register these 2 files:

http://www.vbaccelerator.com/home/VB/Code/Controls/Combo_and_List_Boxes/Owner_Draw_Combo_and_List_Box/VB6_Owner_Draw_Combo_List_Control.zip

=and=

http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/SSubTimer/VB6_SSubTmr_Binary.zip

Once unzipped, copy the 2 files to your windows\system32 directory

From the command window, register the 2 files:

regsvr32 SSubTmr.DLL

=and=

regsvr32 vbalODCL6.ocx

Now you can add the control to your project.  From the menu: Project->Components select "vbaccelerator Owner Draw Combo..."

And then to test it our in your form:

Private Sub Form_Load()

With OwnerDrawComboList1

'Set the combo style
.ClientDraw = ecdColourPickerNoNames

'Add the colors
.AddItemAndData "Blk", , , , RGB(8, 8, 8)
.AddItemAndData "Brn", , , , RGB(128, 64, 16)
.AddItemAndData "Red", , , , RGB(200, 32, 32)
.AddItemAndData "Orn", , , , RGB(240, 148, 32)
.AddItemAndData "Yel", , , , RGB(240, 240, 32)
.AddItemAndData "Grn", , , , RGB(32, 200, 32)
.AddItemAndData "Blu", , , , RGB(32, 32, 200)
.AddItemAndData "Vil", , , , RGB(200, 32, 240)
.AddItemAndData "Gra", , , , RGB(128, 128, 128)
.AddItemAndData "Wht", , , , RGB(250, 250, 250)

.ListIndex = 0

'...

'Good Luck
0
 
LVL 6

Expert Comment

by:mmusante
ID: 12367483
You can try using the imagecombo control ...
0
 
LVL 6

Expert Comment

by:mmusante
ID: 12367559
Try this you need a form with a imagecombo, a picture box (make it small) and a imagelist control


Private Sub Form_Load()
   
    Dim Ci As ComboItem
   
    With Picture1
        .BackColor = vbRed
        ImageList1.ListImages.Add , "RED", .Image
        .BackColor = vbBlue
        ImageList1.ListImages.Add , "BLUE", .Image
        .BackColor = vbGreen
        ImageList1.ListImages.Add , "GREEN", .Image
    End With
   
    Set ImageCombo1.ImageList = ImageList1
    With ImageCombo1.ComboItems
        Set Ci = .Add(, "RED", "RED", "RED")
        Set Ci = .Add(, "BLUE", "BLUE", "BLUE")
        Set Ci = .Add(, "GREEN", "GREEN", "GREEN")
    End With
End Sub
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12376801
Have you seen the way it was done here:

http://www.mbarron.net/Resistor
0
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 12421368
Image Combo Box control does exactly the same thing that you want to. Try searching MSDN for ImageCombo Control

try this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_other/html/dtlrfImageComboControlVisualBasic6.asp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question