Agile Developer

Agile Developer

  • NA
  • 21
  • 3.8k

Combo box color not being applied to text

May 4 2014 1:49 PM
Hello,

I have a combo box which lists all the known windows color. I want the selected color combo box color stored and applied to a string in another location.


The following method adds color to a combo box I have in a form -

private void _tlpMain_Paint(object sender, PaintEventArgs e)
 {
        foreach (System.Reflection.PropertyInfo prop in typeof(Color).GetProperties())
        {
        if (prop.PropertyType.FullName == "System.Drawing.Color")
        _cmbgroupcolor.Items.Add(prop.Name);

        String groupcolor = (string)_cmbgroupcolor.SelectedItem;  //store color
}


In the last line I am trying to store the color in a variable.

In another class, I want to call this color -

node.ForeColor = groupcolor;  //add color to text


I am getting an error saying the "groupcolor" is not found in the current context. I need to somehow make it public so this other class can find it. They are in the same namespace.

Thank you.


Answers (12)