siki
asked on
How to change DBEdit read-only color?
I have form with DBEdits. Some of them (or all) became read-only at runtime. How to change DBEdit color
(in read-only state at runtime) to color different than white nad back to normal when it's not read-only?
Changes occurs on Dataset state change.
(in read-only state at runtime) to color different than white nad back to normal when it's not read-only?
Changes occurs on Dataset state change.
Hi
In your form show event try this
if ded_alotdate.ReadOnly = true then
begin
ded_alotdate.Color := clred;
end else
begin
ded_alotdate.Color := clwindow;
end;
Regards
Pandian
In your form show event try this
if ded_alotdate.ReadOnly = true then
begin
ded_alotdate.Color := clred;
end else
begin
ded_alotdate.Color := clwindow;
end;
Regards
Pandian
Hi Pandian
sinisanenkov said:
>Changes occurs on Dataset state change.
but what you post as answer will check first time when form show, and if the state changed again it will not change the color :)
sinisanenkov said:
>Changes occurs on Dataset state change.
but what you post as answer will check first time when form show, and if the state changed again it will not change the color :)
Yeah that was my understanding that the readonly would change at various times troughout the apps life.
Here is the same example from before but with some changes,
procedure TForm1.Button1Click(Sender : TObject);
begin
DBEdit1.ReadOnly := not DBEdit1.ReadOnly;
SetDBEditColor(DBEdit1);
end;
procedure TForm1.SetDBEditColor(Send er: TDBEdit);
begin
If Sender.ReadOnly then begin
Sender.Color := clBtnFace;
Sender.Font.Color := clBtnText;
end
else begin
Sender.Color := clWindow;
Sender.Font.Color := clWindowText;
end;
end;
Here is the same example from before but with some changes,
procedure TForm1.Button1Click(Sender
begin
DBEdit1.ReadOnly := not DBEdit1.ReadOnly;
SetDBEditColor(DBEdit1);
end;
procedure TForm1.SetDBEditColor(Send
begin
If Sender.ReadOnly then begin
Sender.Color := clBtnFace;
Sender.Font.Color := clBtnText;
end
else begin
Sender.Color := clWindow;
Sender.Font.Color := clWindowText;
end;
end;
Yeah that was my understanding that the readonly would change at various times troughout the apps life.
Here is the same example from before but with some changes,
procedure TForm1.Button1Click(Sender : TObject);
begin
DBEdit1.ReadOnly := not DBEdit1.ReadOnly;
SetDBEditColor(DBEdit1);
end;
procedure TForm1.SetDBEditColor(Send er: TDBEdit);
begin
If Sender.ReadOnly then begin
Sender.Color := clBtnFace;
Sender.Font.Color := clBtnText;
end
else begin
Sender.Color := clWindow;
Sender.Font.Color := clWindowText;
end;
end;
Here is the same example from before but with some changes,
procedure TForm1.Button1Click(Sender
begin
DBEdit1.ReadOnly := not DBEdit1.ReadOnly;
SetDBEditColor(DBEdit1);
end;
procedure TForm1.SetDBEditColor(Send
begin
If Sender.ReadOnly then begin
Sender.Color := clBtnFace;
Sender.Font.Color := clBtnText;
end
else begin
Sender.Color := clWindow;
Sender.Font.Color := clWindowText;
end;
end;
Sorry for the double post my finger flitched, really it did. :>)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
NO, PANDIAN! Your solution dosn't working. VSF posted good comment. It's about DBEdits, not simple TEdits. I am littke bit souprised, how hard is to change simple disabled edit color. I think, VB have done this in properties of comp.
ASKER
NO, PANDIAN! Your solution dosn't working. VSF posted good comment. It's about DBEdits, not simple TEdits. I am littke bit souprised, how hard is to change simple disabled edit color. I think, VB have done this in properties of comp.
ASKER
NO, PANDIAN! Your solution dosn't working. VSF posted good comment. It's about DBEdits, not simple TEdits. I am littke bit souprised, how hard is to change simple disabled edit color. I think, VB have done this in properties of comp.
ASKER
NO, PANDIAN! Your solution dosn't working. VSF posted good comment. It's about DBEdits, not simple TEdits. I am littke bit souprised, how hard is to change simple disabled edit color. I think, VB have done this in properties of comp.
I'm glad I could help!
and thanks for the points.
VSF
www.enge.cjb.net
www.victory.hpg.com.br
UIN:14016999
and thanks for the points.
VSF
www.enge.cjb.net
www.victory.hpg.com.br
UIN:14016999
procedure TForm1.Button1Click(Sender
begin
with DBEdit1 do begin
ReadOnly := not ReadOnly;
If ReadOnly then begin
Color := clBtnFace;
Font.Color := clBtnText;
end
else begin
Color := clWindow;
Font.Color := clWindowText;
end;
end;
end;