>From:  Andrew Masters [SMTP:[EMAIL PROTECTED]]
>Hi All,
>Can anyone tell me how you can Add and Delete persistent fields at
runtime ? 

Firstly, don't do it if you can avoid it.

But if you can't avoid it, use the following to set things up at
runtime.  This only works when you start off with no persistent fields
defined on your form, BTW, but it does allow you to add them on the fly.
I'm not sure whether you can delete them once you've initialised them
(haven't tried it) but then I'm not sure why you'd want to anyway.  I'm
going to assume you're using TQuerys, not TTables, and if so you can
modify your SQL appropriately.

// So you can access protected properties of TDataSet
type TCheatDataSet = class(TDataSet);

// Create the default set of persistent fields for your query sql

// Create other fields of your own.  For example, a calculated field:
        with TStringField.Create(qMyQuery) do begin
                FieldName := <you fill in>;
                FieldKind := fkCalculated;
                Calculated := True;
                Size := <you fill in>;
                DataSet := qMyQuery;


Carl Reynolds                      Ph: +64-9-4154790
CJN Technologies Ltd.             Fax: +64-9-4154791
[EMAIL PROTECTED]                DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to