This is probably a silly question and the answer is obvious but I'm blowed if I can find it - How do you change the color of the font on a disabled TEdit box? Just specific ones not system wide.
By default, disabled edit controls are painted with a greyed text font. There are two basic choices:
1. Place the edit control in a container, like a tPanel, and then use something like this to manage the Font color of the edit box:
Code:
var
cFontColor : TColor;
begin
With Edit1 do
begin
if Parent.enabled then
cFontColor := clBlack
else
cFontColor := clRed;
Font.Color := cFontColor;
end;
end;
This is easy, but could (depending on your form and the version(s) of Windows your application run under) raise the resource requirements.
2. Create a new tEdit (or tCustomEdit) descendent that overrides the painting. There's a good starting place at
it also handles the background color of the Edit control.
This is perhaps the best approach from an engineering persepctive; you'd simply use your new component for those edit boxes that need the font color changed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.