mza1979m Posted April 16, 2003 Posted April 16, 2003 In VB.NET, what is the syntax for checking the forecolor of a certain control? For instance, I want to check if the forecolor of my GroupBox control is Red, and if so, perform a certain action. I tried the following, but no luck: If grpTextAttributes.ForeColor = System.Drawing.Color.Red Then ' Block of code here End If Quote
*Experts* Nerseus Posted April 16, 2003 *Experts* Posted April 16, 2003 Comparing the ForeColor the way you're showing works fine for me. Are you sure it's actually System.Drawing.Color.Red and not just the color "red"? I tried this by using the ForeColor property of a TextBox and a GroupBox control, both worked just fine. I used C# but I don't think it would make a difference. -Ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
mza1979m Posted April 16, 2003 Author Posted April 16, 2003 Well, when I use the code I displayed above, I get the following error: Operator '=' is not defined for types 'System.Drawing.Color' and 'System.Drawing.Color'. When I use just 'Red' instead of 'System.Drawing.Color.Red', it says that the name 'Red' is not declared. Quote
*Experts* Nerseus Posted April 16, 2003 *Experts* Posted April 16, 2003 Weird, you can do this in C#. Try this instead: If TextBox1.ForeColor.Equals(System.Drawing.Color.Red) Then Debug.WriteLine("red") Else Debug.WriteLine("not red") End If -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.