Click here to Skip to main content
15,868,049 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have make a Custom Color Picker and made a combo box so the names of the colors appear in it, how can I make a messagebox appear after selecting the color in the combobox

Also im trying to store that color into the databse with an insert is there anyway to do it


Below is my code for displaying the colors in the ComboBox


VB
Private Sub frmRegAsam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      'load de colores'
      Dim ColorList As New ArrayList()
      Dim colorType As Type = GetType(System.Drawing.Color)
      Dim propInfoList As PropertyInfo() = colorType.GetProperties(BindingFlags.[Static] Or BindingFlags.DeclaredOnly Or BindingFlags.[Public])
      For Each c As PropertyInfo In propInfoList
          Me.cboVotante.Items.Add(c.Name)
          Me.cboSuplente.Items.Add(c.Name)
      Next

  End Sub
Posted
Comments
Sergey Alexandrovich Kryukov 26-Mar-13 17:34pm    
System.Windows.Forms? Tag: "WinForms".
What's the problem, exactly? You are not trying to work with the database in this code sample.
—SA
[no name] 26-Mar-13 20:32pm    
Why can you not create a combobox selection changed event? Are you unable to show a messagebox? If your "problem" is either the first or the second, why did you post code for something that has nothing to do with either? And there is no indication that you have tried anything with a database, as stated by Sergey. So what does a database have to do with the code you posted?

1 solution

1. Use the combobox selected index change event to trap the event.
2. Create function called display color
3. Function DisplayColor should display a new form with the background set to the combobox selected value

It will be easier to create your own form rather use a messagebox object.

If you want to save the selected values to the database then just insert into a table the colorname you added to the combobox.

I am assuming you need other fields in there like userid perhaps, to fetch user preferences.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900