正在写一个小程序,里面有很多form都会用到TDateTimePicker,现在想让TDateTimePicker默认显示系统当前时间,但是不想在每个formcreat里重复写,想问问写个过程让每个formcreat调用该怎么写,我已经默认让每个TDateTimePicker名称的前三个字为相同的字了,希望能有高手指点,急,希望能有代码赐教,谢谢各位了.保证及时上分
调试欢乐多
begin
tempdtp.DateTime := now;
end;
var
I: Integer;
FComp: TComponent;
begin
Result := False;
if Assigned(Owner) then
for I := 0 to Owner.ComponentCount - 1 do
begin
FComp := Owner.Components[I];
Result := (FComp is TDateTimePicker) and (Pos(SubName, FComp.Name) > 0);
if Result then
TDateTimePicker(FComp).DateTime := DT
else Result := FindDateTimePicker(FComp, SubName, DT);
end;
end;
DateTimePicker.DateTime:= now;
for x := 0 to Self.ComponentCount – 1 do
if Self.Components[x] is TDateTimePicker then
TDateTimePicker(Self.Components[x]).DateTime := now;