Board index » delphi » Add fields to Field Editor (of a Table) at runtime

Add fields to Field Editor (of a Table) at runtime

Quote
>>MyTable.FieldByName('MName').OnChange := MyTableFieldChange;

There is nothing wrong with this code. What error message are you getting?
Does the error occur at compile time or at run time?

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

 

Re:Add fields to Field Editor (of a Table) at runtime


I want to associate the OnChange Event of a Field (say, 'MName') in a Table,
to a procedure that I defined, at runtime. However, I found that I cannot
correctly associate the two as expected.
But it is possible when I have the field 'MName' added in the Field Editor
of the Table (I have tried this at design time).  I guess that may be as I
used the code below:

MyTable.FieldByName('MName').OnChange := MyTableFieldChange;

but the compiler cannot locate the TField object that is named 'MName'? I
have used de{*word*81} to inspect the value of "MyTable.FieldByName('MName')"
and found that it is inaccessible.

So, how can I add a field to Field Editor (of a Table) at runtime? Or any
other suggestions on solving this problem? By the way, I used
ApolloDatabase, ApolloTable, does it make any difference?

Re:Add fields to Field Editor (of a Table) at runtime


Quote
> There is nothing wrong with this code. What error message are you getting?
> Does the error occur at compile time or at run time?

It does not cause any error message, I just cannot get the method (that is
associated with the OnChange event) called when the Field has changed.

Re:Add fields to Field Editor (of a Table) at runtime


Just to say that I have found the core problem (and is solved). I actually
have associated the event handler successfully. Their connection is,
however, lost when I set the Active property of the TTable object from false
to true.

Re:Add fields to Field Editor (of a Table) at runtime


Yes. TTable recreates the field objects each time it is opened so you will
have to reconnect the event handler when you open the TTable.

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Other Threads