Well, I suppose he could just do the same for the ForeColor as what I did
for the BackColor.
I really had 2 minutes so I just showed the trick with one color.
Regards,
Fabrizio
What about the ForeColor?
--
HTH
Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (
www.s2i.com)
http://emoreau.s2i.com/
My first guess would be doing something like that:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledTextBox : System.Windows.Forms.TextBox{
Color disabledBackColor, originalBackColor;
public CustomDisabledTextBox() {
disabledBackColor = Color.LightBlue; // or whatever you like
}
protected override void OnEnabledChanged(EventArgs e) {
if (!this.Enabled) {
this.originalBackColor = this.BackColor;
this.BackColor = disabledBackColor;
} else {
this.BackColor = originalBackColor;
}
base.OnEnabledChanged(e);
}
[Browsable(true)]
public Color DisabledBackColor {
get {
return this.disabledBackColor;
}
set {
this.disabledBackColor = value;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
And use this textbox.
When the Enable state changes in the overridden method you place the
desired color. If the control is disabled you place yours, otherwise
the original one.
Also, adding the property accessor with the [Browsable(true)] attribute
let's you define the disabled back color at design time.
Done in 2 minutes so don't take this at 100% best solution ok?
Regards
Fabrizio
I'm using krypton toolkit which has allowed me to make a cool looking
form. However, when I set my textbox to disabled it is 'greyed' out.
The grey colour isn't in keeping with the office 2007 style look ofmy
form. How can i change the colour that control assumed when it's
disabled?
Thanks!
Gary-