473,756 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change the colour of the disabled state of a control?

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 of my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-

Jan 5 '07 #1
7 11814
My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@myw ay.comwrote in message
news:11******** **************@ s80g2000cwa.goo glegroups.com.. .
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 of my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-

Jan 5 '07 #2
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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@myw ay.comwrote in message
news:11******** **************@ s80g2000cwa.goo glegroups.com.. .
>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 of my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-


Jan 7 '07 #3
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

"Eric Moreau" <er************ *********@video tron.cawrote in message
news:uG******** ******@TK2MSFTN GP03.phx.gbl...
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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
>My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@my way.comwrote in message
news:11******* *************** @s80g2000cwa.go oglegroups.com. ..
>>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 of my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-



Jan 8 '07 #4
Your BackColor implementation is working correctly but the ForeColor isn't.
It has always been the problem of disabled controls.

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
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

"Eric Moreau" <er************ *********@video tron.cawrote in message
news:uG******** ******@TK2MSFTN GP03.phx.gbl...
>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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******* *************** *@reader4.news. tin.it...
>>My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@m yway.comwrote in message
news:11****** *************** *@s80g2000cwa.g ooglegroups.com ...
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 of my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-



Jan 8 '07 #5
You're right.
It seems that there is not an easy solution, at least in the first 20/30
results on google and I'm not even talking about msdn...
Maybe he could just do the background trick I suggested setting the ReadOnly
property to false instead of disabling the control.
And if he also wants the control not to be selectable he could just handle
the Enter() event giving the focus to some other control.
What would you suggest?

Regards,
Fabrizio
"Eric Moreau" <er************ *********@video tron.cawrote in message
news:OY******** *******@TK2MSFT NGP04.phx.gbl.. .
Your BackColor implementation is working correctly but the ForeColor
isn't. It has always been the problem of disabled controls.

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
>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

"Eric Moreau" <er************ *********@video tron.cawrote in message
news:uG******* *******@TK2MSFT NGP03.phx.gbl.. .
>>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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45****** *************** **@reader4.news .tin.it...
My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@ myway.comwrote in message
news:11***** *************** **@s80g2000cwa. googlegroups.co m...
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 of my
form. How can i change the colour that control assumed when it's
disabled?
>
Thanks!
>
Gary-
>




Jan 8 '07 #6
I have just had a chance to spot the replies. Thankyou both some ideas
to get me started.
I'm going to have a play with this over the next couple of days. It's a
shame there isn't an easy way to change the colour that the control
assumes when its disabled - I would have thought this was a basic
requirement! But I guess not.

Thanks for the kind help,

Gary.

Fabrizio Romano wrote:
You're right.
It seems that there is not an easy solution, at least in the first 20/30
results on google and I'm not even talking about msdn...
Maybe he could just do the background trick I suggested setting the ReadOnly
property to false instead of disabling the control.
And if he also wants the control not to be selectable he could just handle
the Enter() event giving the focus to some other control.
What would you suggest?

Regards,
Fabrizio
"Eric Moreau" <er************ *********@video tron.cawrote in message
news:OY******** *******@TK2MSFT NGP04.phx.gbl.. .
Your BackColor implementation is working correctly but the ForeColor
isn't. It has always been the problem of disabled controls.

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
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

"Eric Moreau" <er************ *********@video tron.cawrote in message
news:uG******** ******@TK2MSFTN GP03.phx.gbl...
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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******* *************** *@reader4.news. tin.it...
My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@m yway.comwrote in message
news:11****** *************** *@s80g2000cwa.g ooglegroups.com ...
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-


Jan 8 '07 #7
Glad if I helped a little.
Cheers
Fabrizio

<ga********@myw ay.comwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
I have just had a chance to spot the replies. Thankyou both some ideas
to get me started.
I'm going to have a play with this over the next couple of days. It's a
shame there isn't an easy way to change the colour that the control
assumes when its disabled - I would have thought this was a basic
requirement! But I guess not.

Thanks for the kind help,

Gary.

Fabrizio Romano wrote:
You're right.
It seems that there is not an easy solution, at least in the first 20/30
results on google and I'm not even talking about msdn...
Maybe he could just do the background trick I suggested setting the
ReadOnly
property to false instead of disabling the control.
And if he also wants the control not to be selectable he could just handle
the Enter() event giving the focus to some other control.
What would you suggest?

Regards,
Fabrizio
"Eric Moreau" <er************ *********@video tron.cawrote in message
news:OY******** *******@TK2MSFT NGP04.phx.gbl.. .
Your BackColor implementation is working correctly but the ForeColor
isn't. It has always been the problem of disabled controls.

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******** *************** @reader4.news.t in.it...
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

"Eric Moreau" <er************ *********@video tron.cawrote in message
news:uG******** ******@TK2MSFTN GP03.phx.gbl...
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/

"Fabrizio Romano" <fa******@tin.i twrote in message
news:45******* *************** *@reader4.news. tin.it...
My first guess would be doing something like that:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class CustomDisabledT extBox : System.Windows. Forms.TextBox{

Color disabledBackCol or, originalBackCol or;

public CustomDisabledT extBox() {
disabledBackCol or = Color.LightBlue ; // or whatever you like
}

protected override void OnEnabledChange d(EventArgs e) {
if (!this.Enabled) {
this.originalBa ckColor = this.BackColor;
this.BackColor = disabledBackCol or;
} else {
this.BackColor = originalBackCol or;
}
base.OnEnabledC hanged(e);
}

[Browsable(true)]
public Color DisabledBackCol or {
get {
return this.disabledBa ckColor;
}
set {
this.disabledBa ckColor = 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

<ga********@m yway.comwrote in message
news:11****** *************** *@s80g2000cwa.g ooglegroups.com ...
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 of
my
form. How can i change the colour that control assumed when it's
disabled?

Thanks!

Gary-



Jan 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3205
by: Craig | last post by:
I have a page that has a few columns and totals. I've been asked to amke sure that not only is the totals boxes readonly, they must not accept focus from the cursor. However, setting the bo to Disabled makes the font go inverted it seems. I'd like to be able to still control the colour of these boxes, both the background and foreground, but not makethem the light grey that they are going at the moment.
6
5236
by: Louise | last post by:
Hi I have written an HTML pages which does not have any colour specifying tags as far I know. When I view this in an Microsoft internet explorer browser it appears with a white background and black text but when I change Windows start menu->settings->control panel ->display -> appearance and change scheme to 'High Contrast Black' the background in the browser changes to black and the text to white. I understand that the windows scheme...
2
6629
by: Scott | last post by:
Is it possible to have a button change colour OnClick ? Thanks.
4
5676
by: | last post by:
Please, help. I created my contol, ButtonX, which subclasses System.Forms.Windows.Button class. I am doing my own paiting, by overriding OnPaint and OnPaintBackground (without calling base class's OnPaint & OnPaintBackground). My button has a shape of rectangle with rounded corners and is filled with gradient brush, where user specifies the gradient colors. The dilema I have now is how to paint the button when it's disabled (Enabled =...
6
4483
by: Mantorok | last post by:
Hi all Is it possible to disable a Control in .Net but have the text colour always in black? I would rather use Enabled property rather than Readonly as it does everything I need it to in one swoop (no tabstop, no focus etc.). Any ideas?
2
7145
by: Kubuli John | last post by:
I have a LinkButton in an ASP.NET web form. Depending on the current state of affairs, I either enable or disable the link button in by code-behind class (e.g., disable the "Previous" button if you are already at the first record). I have constructed a very nice style for the button in my stylesheet, but the style is ignored when I disable the button. So, how do I control the display attributes of a disabled HTML widget? Thanks...
4
2427
by: Mel | last post by:
how can i change disabled background on all form elements ?
4
8600
by: Bob | last post by:
Hi, Is it possible to change the forecolor of a disabled text control. I have a RichText Box that I don't want the user to edit but the Grey on Grey default is hard to read. Is there a way of overriding this with a custom colour? I had a quick foray into the forms Paint event handler but no joy. Thanks Bob
3
2423
by: helraizer1 | last post by:
Hi all, On one page of my site I have a form (code below) with an input textbox with the id "message". You type in your message in this field (as the id suggests) and depending on an option in a select element (still part of the form) the text of 'message box' changes to that colour. form: <form id="input" method="post" action="<?php echo $PHP_SELF; ?>"> Name: <input id="username" type="text" name="username"...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.