Subject | RE: [IBO] TIB_Grid: Autofill on date fields |
---|---|
Author | Alan McDonald |
Post date | 2007-01-28T22:40:17Z |
> Hi,--
>
> how can I set Autofill for date fields in a TIB_Grid?
>
> What I tried was putting a TIB_Date control onto the grid
> and setting the DataSource and DataField properties of the date control.
> But the date control seems not to be used..
>
> I also tried something like the following but do not know how to
> get my text into the field - see the first commented line.
>
>
> procedure TMyForm.MyGridKeyPress(Sender: TObject; var Key: Char);
> var
> nowyy,nowmm,nowdd:WOrd;
> begin
> inherited;
> if (key>='0') and (key<='9') then begin
> if (Sender as TIB_Grid).SelectedField.IsDateTime then begin
> DecodeDate(Now,nowyy,nowmm,nowdd);
> nowdd := (ord(key)-ord('0'))*10 + nowdd mod 10;
> // (Sender as TIB_Grid).SelectedField.Text :=
> // ReplaceChars(Format('%2d.%2d.%2d',[nowdd,nowmm,nowyy]),' ','0');
> end;
> end;
> end;
>
>
>
Wolfgang
not sure what you mean by "pre-fill" - do you mean that the grid has
existing records you want to overwrite? or do you mean when a new record is
inserted? if the latter then just use the query oninsert event to assign
SysUtils.Now to the field.
Alan