Hello, all.
If I create a new unigui component at runtime:
var
aNewUniComponent: TObject;
begin
aNewUniComponent:=TUniDBMemo.Create(self);
...
then I wish to associate it with a Data Field. I know it's a data-aware control, so I should be able to do the following:
TUniDBEdit(aNewUniComponent).DataField:='aFieldName';
whether it's a TUniDBEdit, TUniDBMemo, TUniDBNumberEdit, etc.
This fails, however, with an access violation, although I am not sure why, and only works with the exact same class:
TUniDBMemo(aNewUniComponent).DataField:='aFieldName';
otherwise I may get an Invalid Pointer Operation error.
My Question is if there is a Class from which all data-aware unicontrols descend such that I can typecast without access violations, such as
TUniDBControl(aNewUniComponent).DataField:='aFieldName';
Other wise I need to use a series of if then else statements like:
if ClassName='TUniDBEdit' then
TUniDBEdit(aNewComponent).DataField:='aFieldName' else
if ClassName='TUniDBMemo' then
TUniDBMemo(aNewComponent).DataField:='aFieldName' else
if ClassName='TUniDBNumberEdit' then
TUniDBNumberEdit(aNewComponent).DataField:='aFieldName' else
etc.
or perhaps there is a better way?
Thank you in advance
Doug