471,337 Members | 888 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Visual Studio and Custom Control colors

I have code like this:

public class MyControl: Control
{
public MyControl()
{
this.BackColor = MyStandardBackColor;
}

public bool ShouldSerializeBackColor()
{
return BackColor != MyStandardBackColor;
}

public void ResetBackColor()
{
BackColor = MyStandardBackColor;
}
}

However, I have found that the VS2005 designer sets the control
backcolor to the Microsoft gray after MyControl is constructed. Is
there a way to prevent this from happening, so that my developers do
not have to go and manually reset the BackColor property of every
control?

Is there anyone at Microsoft who might be interested in this problem.
My bug reports are never acknowledged.

Jan 12 '06 #1
4 1508
Don't set it in the constructor.

"kevin cline" <ke*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have code like this:

public class MyControl: Control
{
public MyControl()
{
this.BackColor = MyStandardBackColor;
}

public bool ShouldSerializeBackColor()
{
return BackColor != MyStandardBackColor;
}

public void ResetBackColor()
{
BackColor = MyStandardBackColor;
}
}

However, I have found that the VS2005 designer sets the control
backcolor to the Microsoft gray after MyControl is constructed. Is
there a way to prevent this from happening, so that my developers do
not have to go and manually reset the BackColor property of every
control?

Is there anyone at Microsoft who might be interested in this problem.
My bug reports are never acknowledged.

Jan 12 '06 #2
Did you have an alternative in mind?

Jan 13 '06 #3
You need to override the BackColor Property and apply the DefaultValue
attribute. In the constructor set the this.BackColor = MyStandardBackColor.
Forget what I said about not setting the color in the constructor, my bad.
"kevin cline" <ke*********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Did you have an alternative in mind?

Jan 13 '06 #4

Rocky wrote:
You need to override the BackColor Property and apply the DefaultValue
attribute. In the constructor set the this.BackColor = MyStandardBackColor.
Forget what I said about not setting the color in the constructor, my bad.


There is no way to apply the DefaultValue attribute, because the
default back color is computed from a configuration file.

Jan 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by SL33PY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.