Board index » delphi » Creating controls in a TDBCtrlGrid at runtime

Creating controls in a TDBCtrlGrid at runtime

Hi all,

Somebody know how to create controls in a TDBCtrlGrid at runtime.
I tried this code, but controls are created only in the first panel.

procedure TForm1.FormCreate(Sender: TObject);
begin
    with TDbedit.Create(Owner) do
    begin
      Parent := dbCtrlGrid1;
      DataSource := dbCtrlGrid1.DataSource;
      DataField := 'MyField';
      ...
    end;
end;

Thanks
Francesco Frau
Modasystem S.r.l.

 

Re:Creating controls in a TDBCtrlGrid at runtime


Hello Francesco,

type
  TMyGrid = class(TDBCtrlGrid);

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TDBEdit.Create(Owner) do
  begin
    Parent := TMyGrid(DBCtrlGrid1).Panel;
    DataField := 'MyField';
  end;
end;

The grid sets DataSource for the control implicitly.

--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com

Quote
"Francesco Frau" <francesco.f...@modasys.it> wrote in message

news:3cc43903_2@dnews...
Quote
> Hi all,

> Somebody know how to create controls in a TDBCtrlGrid at runtime.
> I tried this code, but controls are created only in the first panel.

> procedure TForm1.FormCreate(Sender: TObject);
> begin
>     with TDbedit.Create(Owner) do
>     begin
>       Parent := dbCtrlGrid1;
>       DataSource := dbCtrlGrid1.DataSource;
>       DataField := 'MyField';
>       ...
>     end;
> end;

> Thanks
> Francesco Frau
> Modasystem S.r.l.

Re:Creating controls in a TDBCtrlGrid at runtime


 Thank you very much Andrei, it works fine.

 Francesco Frau
 Modasystem S.r.l.

Other Threads