端
端木飘零
Unregistered / Unconfirmed
GUEST, unregistred user!
我的窗体里有很多TDBEdit,我想在每个TDBEdit的OnExit中判断TDBEdit的值,如果值不为空,则颜色为红色,如果为空,则颜色为灰色,怎么实现?
procedure Tfrm_yw_szfx1.Button1Click(Sender: TObject);
var i:integer;
begin
with ScrollBox1do
for i:=0 to ControlCount-1do
begin
if (Controls is TDBEdit) then
with Controls as TDBEditdo
begin
if text='' then
begin
Font.Color:=clGray;
end
else
begin
Font.Color:=clBlue;
end;
end;
end;
end;
上面这段代码属于遍历所有控件,有点浪费,如何将这段代码修改,让他作为每个Tdbedit的onexit事件触发事件?
procedure Tfrm_yw_szfx1.Button1Click(Sender: TObject);
var i:integer;
begin
with ScrollBox1do
for i:=0 to ControlCount-1do
begin
if (Controls is TDBEdit) then
with Controls as TDBEditdo
begin
if text='' then
begin
Font.Color:=clGray;
end
else
begin
Font.Color:=clBlue;
end;
end;
end;
end;
上面这段代码属于遍历所有控件,有点浪费,如何将这段代码修改,让他作为每个Tdbedit的onexit事件触发事件?