tField.validate in tdbGrid

tField.validate in tdbGrid

Post by Clayton J Andre » Sat, 24 Feb 1996 04:00:00



Greetings all,

Could someone please tell me how to get the original value of a tField
before posting to the record.

field.validate
{
 validate_data;
 otherfield.value:=field.value;

Quote:}

I was under the impression that field.text contains the new value to
be validated, while the .value retains the original. It seems
impossible to access the original value once the user has modified the
field, but I know it must be possible, as the 'rollback' can be done
if the user presses [esc] to abort the edit.

Can anyone see my problem here? Any solutions?
---
Clayton Andrews, Cape Town, ZA

 
 
 

tField.validate in tdbGrid

Post by Steve Koters » Tue, 27 Feb 1996 04:00:00




Quote:>Greetings all,

>Could someone please tell me how to get the original value of a tField
>before posting to the record.

>field.validate
>{
> validate_data;
> otherfield.value:=field.value;
>}

>I was under the impression that field.text contains the new value to
>be validated, while the .value retains the original. It seems
>impossible to access the original value once the user has modified the
>field, but I know it must be possible, as the 'rollback' can be done
>if the user presses [esc] to abort the edit.

I would use a procedure based on the BeforeEdit event of the TTable, and
store the pre-edit value to a memory variable. This same value will then be
available until you either clear the variable (as would be done after a
posting, e.g., AfterPost event) or until a new record is changed to edit
mode. For example:

  procedure TForm1.Table1BeforeEdit(DataSet: TDataset);
  begin
    Edit5.Text := Table1Text.AsString;
  end;

**************************************************************************
Steve Koterski                  "Results! Why, man, I have gotten a lot of
Product Group Manager           results. I know several thousand things
Delphi Technical Support        that won't work."
Borland International, Inc.                    -- Thomas Edison, 1847-1931

 
 
 

1. TDbgrid Tfield quesiotn..

: I Have a problems with delphi, I wish elements in a  DBgrid whose
: value is equal to '-1' to be   displayed as 'N/A' is this possible?
: I've been    playing  with the events of the DBgrid  and Tfield but I
: can't  figure which one to use, or which property to change.

: Thanks

: Carlos Santillan

You should define CALCULATED string field. That can be done
with using the field editor on your  DBGrid's dataset (the underlying
table or query). The online help will tell you how to do this.

Suppose now for the sake of the argument that you are working with table1,
and that the original field and new calculated field have names
table1Int and Table1Str, respectively.

Two more steps are necessary:

1) Place code similar to the following  in the  OnCalcField event handler
   of table1:

   if Table1Int.AsInteger=-1 then Table1Str.AsString:='N/';
      {of course you can also use else ... or a case statement...}

2) Don't forget to change TableInt.Visible to false (using the field editor
   again) if you don't want the original column to be displayed.

Hope this helps,

                                                  Andy

2. Word export filter for Quickreport

3. FieldByName() or TFields

4. How user access V7.3.2 and V8.16 from same PC

5. Extending TField subclasses

6. SQL Server Design Issue with Identity Columns

7. HELP : TFIELD.WIDTH PROBLEM

8. Informix DBA/Engineer needed in Atlanta GA

9. How to derive new class from TField ?

10. How to create Persistent TFields at runtime????

11. Passing a TField object as a parameter?

12. TFields' DisplayLabel vs DisplayName