0
So I misunderstood your question. I thought that what you were trying to do was not that simple.
0
Looks like I tried to over-engineer the solution.
It really is as simple as it should be.
This works:
if (comboBoxTrafficStatus.SelectedItem.ToString() == "RED")
{
labelTrafficStatus.ForeColor = System.Drawing.Color.Red;
comboBoxTrafficStatus.ForeColor = System.Drawing.Color.Red;
}
Thanks again.
0
My apology for using a colloquialism vs. an MSDN specific error message.
Colloquialism: A characteristic
of
or
appropriate
to
ordinary
or
familiar
conversation
rather
than
formal
speech
or
writing;
BARF means to vomit or retch. It is an onomatopoeic word accepted in common usage since 1960.
As
used in my note, it means that the program comes to an abrupt halt and spews forth (vomits / retches) a distasteful expectorate; an error message.
I have disabled the code for the moment so that I can move forward with this project that needs to get done and will come back to it if I have time.
I do appreciate your help and if you have any insight as to how to accomplish the function.
Thanks for working on this seemingly simple function that has me baffled.
0
I searched the MSDN for barf but I am not sure what that is. Is it something that is supposed to happen that is not happening or is it is not happening but supposed to happen or is it an error message? If it is an error message then it is not likely to be the complete error message; can you please provide the complete error message if it is an error message?
0
I have the code for a Status Change Event.
When the program starts up all is well; the color is set according to the value in the comboBox.
The value is coming from an XML file: <FlowStatus>YELLOW</FlowStatus>
The code below will set the comboBoxFlowStatus.ForeColor appropriately.
HOWEVER COMMA...
When the status change event occurs...
Barf!

private void FlowStatusChange_Event(object sender, EventArgs e)
{
if (comboBoxFlowStatus.SelectedItem.ToString() == "RED")
{
this.comboBoxFlowStatus.ForeColor = System.Drawing.Color.Red;
labelFlowStatus.ForeColor = Color.Red;
}
}
0
A combobox is by definiton a combination of a listbox control and an edit control. The edit control is called a textbox control in VB and .Net. If it is possible to use .Net to do what you are trying to do, then it will involve setting proerties for the textbox, but I don't see how to use .Net to get the textbox in the combobox.
So the following
might help, but I have left a lot for you to do and I am not sure if this will do what you need even if you do the rest.
First add "
using System.Runtime.InteropServices;" to the top of the program. Then add the following as members of the form class.
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter,
string lpszClass, string lpszWindow);
IntPtr TextboxHandle = IntPtr.Zero;
Then I think the following will get the handle of the edit control. Note that you will need to do the code to set the color, which might be more work than you want to do, but whatever you do, I think you must do it in a handler of either a WM_CTLCOLOREDIT or a WM_CTLCOLORSTATIC message sent to the form. Also this probably will not work for a DropDownList style.
const string ClassName1 = "Edit";
TextboxHandle = FindWindowEx(comboBox1.Handle, IntPtr.Zero, ClassName1, null);
if (TextboxHandle == IntPtr.Zero)
// did not work
