Jump to content

Recommended Posts

Posted

Hello

 

I found the class TUniBaseControl as base class of all UniGui controls; there are any base class for all DB editors (like UniDBEditor, UniDBCheckBox, etc)? If exists, I will use it to assign common DB properties in runtime like DataField or DataSource.

 

Thx

  • Administrators
Posted

Hello

 

I found the class TUniBaseControl as base class of all UniGui controls; there are any base class for all DB editors (like UniDBEditor, UniDBCheckBox, etc)? If exists, I will use it to assign common DB properties in runtime like DataField or DataSource.

 

Thx

 

There is no common class for DB controls because you can either have a common class for visual controls or for DB controls but not for both.

 

Fortunately in 0.85.0 all classes are redesigned to implement various Interfaces.

 

All DB Controls implement below interface:

 

  IUniDBControl = interface
['{7FD5C254-1303-45D7-AF7C-ED0E319707D9}']
function __GetField: TField;
function __GetDataField: WideString;
procedure __SetDataField(Value: WideString);
function __GetDataSource: TDataSource;
procedure __SetDataSource(Value: TDataSource);

property Field: TField read __GetField;
property DataField: WideString read __GetDataField write __SetDataField;
property DataSource: TDataSource read __GetDataSource write __SetDataSource;
 end;

 

You can code as below:

 

  (ControlX as IUniDBControl).DataField:='Name';

 

Or better:

 

  
if Supports(ControlX, IUniDBControl) then
 (ControlX as IUniDBControl).DataField:='Name';

  • Upvote 1
Posted

Great! This will be enough for me.

 

Thx

 

There is no common class for DB controls because you can either have a common class for visual controls or for DB controls but not for both.

 

Fortunately in 0.85.0 all classes are redesigned to implement various Interfaces.

 

All DB Controls implement below interface:

 

  IUniDBControl = interface
['{7FD5C254-1303-45D7-AF7C-ED0E319707D9}']
function __GetField: TField;
function __GetDataField: WideString;
procedure __SetDataField(Value: WideString);
function __GetDataSource: TDataSource;
procedure __SetDataSource(Value: TDataSource);

property Field: TField read __GetField;
property DataField: WideString read __GetDataField write __SetDataField;
property DataSource: TDataSource read __GetDataSource write __SetDataSource;
 end;

 

You can code as below:

 

  (ControlX as IUniDBControl).DataField:='Name';

 

Or better:

 

  
if Supports(ControlX, IUniDBControl) then
 (ControlX as IUniDBControl).DataField:='Name';

×
×
  • Create New...