uses DateUtils;Это - само заполнение нажатиями пробелов, ну, а после заполнения, уж сам перекинь фокус на другой компонент...
// ...
procedure TForm1.DBEdit1KeyPress(Sender: TObject; var Key: Char);
var curr: TDbEdit;
begin
if Key = #32 then begin
curr := Sender as TDbEdit;
case Length((Sender as TDbEdit).Text) of
0: curr.Text := Format('%2d/', [DayOf(Now)]);
3: curr.Text := curr.Text + Format('%2d/', [MonthOf(Now)]);
6: curr.Text := curr.Text + Format('%4d', [YearOf(Now)]);
end;
curr.SelStart := Length(curr.Text);
curr.SelLength := 0;
Key := #0;
end;
end;
0: curr.Text := Format('%2d/', [DayOf(Now)]);
3: curr.Text := curr.Text + Format('%2d/', [MonthOf(Now)]);
6: curr.Text := curr.Text + Format('%4d', [YearOf(Now)]);
procedure TForm1.DBEdit1KeyPress(Sender: TObject; var Key: Char);
function Conv(w: word; len: integer): string;
begin
result := IntToStr(w);
while Length(result) < len do result := '0' + result;
end;
var curr: TDbEdit;
begin
if Key = #32 then begin
curr := Sender as TDbEdit;
case Length((Sender as TDbEdit).Text) of
0: curr.Text := Conv(DayOf(Now), 2) + '/';
3: curr.Text := curr.Text + Conv(MonthOf(Now), 2) + '/';
// Тут можно и не менять, год всегда четырехзначный
6: curr.Text := curr.Text + Conv(YearOf(Now), 4);
end;
curr.SelStart := Length(curr.Text);
curr.SelLength := 0;
Key := #0;
end;
end;
var d:string;
begin
d:=datetostr;
label1.caption:=(d);
end;
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
if CompareText(Column.Field.FieldName, 'DateOfBirth') = 0 then
begin
if Column.Field.AsString = '' then begin
Column.Field.AsString := DateToStr(Today);
end;
end;
end;