Is it possible that i define

Is it possible that i define

TForm1 = class(TForm)
cxDBTextEdit1: TcxDBTextEdit;
myDM: TmyCustomDatamodule;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

and can select the Datasource in Designtime as "myDM.Datasource1" ?

Comments

  1. The problem you see is that the datamodule is only instantiated at runtime and thus is not available at designtime.

    ReplyDelete
  2. Hi Uwe Raabe , i have tried to create a tmydm_container = class(tcomponent) with a published property myDM which is a instance of tmyDatamodule. I have the new Component on my form which has a property with tDatamodule, i see it but designer does not.

    Actually i have empty tDatasources on my form so i can connect all dbedits to these, on formcreate i go through all components on form and check over RTTI if i can change the datasource like this:

    ... loop self.componentcount
    vComponent:=self.components[i];
    if IsPublishedProp(vComponent, 'Datasource') then begin
    try vdsource := tDatasource(GetObjectProp(vComponent,
    'Datasource', tDataSource)); except vdsource:=nil; end;

    if vdsource<>nil then
    if vdsource=vtempDatasource then
    SetObjectProp(vComponent, 'DataSource', vNewDatasource);
    end;

    and i call it i.e.

    do_switch_ds(mytempDS1, mydm.ds1);
    do_switch_ds(mytempDS2, mydm.ds2);

    but this is slow

    ReplyDelete

Post a Comment