How to change textbox font color when disable ?

E

engteng

When textbox properties enable = False the font in the textbox become gray
color. How do I change the gray color to black color ?


Regards,
Tee
 
P

Phill W.

engteng said:
When textbox properties enable = False the font in the textbox become gray
color. How do I change the gray color to black color ?

If your users have had Windows PC's for more than about three days, then
you should not do this, unless you have a really, /really/ Good Reason
to do so (e.g. specialised applications for, say, poorly-lit working
conditions).

Grey text on disabled controls is /standard/ Windows behaviour that will
be exhibited when your application runs on practically every Windows PC
on the planet.

OK, there /are/ a few cases where this is justifiable; just so long as
(a) you realise that there are /very/ few such cases, and
(b) your users know in advance that your application is going to behave
this way.

Applications that do "odd" things may be reported as "buggy" or
un-installed completely (just try changing the screen resolution on me!)
:)

Regards,
Phill W.
 
J

jp2msft

engteng:

I see what you are trying to do. Instead of setting the TextBox's Enabled
Property to False, try setting the ReadOnly Property to True.

I bet you a dollar this is what you are trying to accomplish.
 
E

engteng

This will do but what is the best way to avoid this textbox to have gotfocus
even it is readonly ?


Regards,
Tee
 
E

engteng

You are right (Gray hard to see) so I am using Windows XP sp3 any way to
change the gray color ?

Regards,
Tee
 
C

Cor Ligthert[MVP]

textbox.Next maybe

Cor

engteng said:
This will do but what is the best way to avoid this textbox to have
gotfocus even it is readonly ?


Regards,
Tee
 
K

kimiraikkonen

This will do but what is the best way to avoid this textbox to have gotfocus
even it is readonly ?

Regards,
Tee









- Show quoted text -

It maybe considered as a primitive way, but you can try to handle your
ReadOnly Textbox's GotFocus event and when it gets focus then focus
another UI control to lose focus of textbox as follows:

'---------------------------------------------------
Private Sub TextBox1_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.GotFocus

' when it gets focus select another control
Textbox1.SelectNextControl

' ...OR focus another control manually
' eg: a button
Button1.Focus

End Sub
'-----------------------------------------------------

Hope this helps,

Onur Güzel
 
K

kimiraikkonen

It maybe considered as a primitive way, but you can try to handle your
ReadOnly Textbox's GotFocus event and when it gets focus then focus
another UI control to lose focus of textbox as follows:

'---------------------------------------------------
Private Sub TextBox1_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.GotFocus

' when it gets focus select another control
Textbox1.SelectNextControl

' ...OR focus another control manually
' eg: a button
Button1.Focus

End Sub
'-----------------------------------------------------

Hope this helps,

Onur Güzel- Hide quoted text -

- Show quoted text -

Regarding to SelectNextControl in my previous post, as i forgot, don't
forget to pass required arguments mentioned on:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.selectnextcontrol.aspx

...or selecting / focusing a specific control manually like button
would be shorter way to make your textbox lose focus when it gets
focus :)

Thanks,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top