Criação de componentes em tempo de execução

问题描述 投票:0回答:0

galera estou com um problema pra criar objetos em rum time no delphi.... estou criando um dbctrlgrid e dentro dele um painel com alguns edits...o problema é que o painel nao ta ficando contido dentro de uma celula do dbctrlgrid eles esta expandindo alclient de todo 或 dbctrlgrid

DBGrid:= TDBCtrlGrid.Create(Page);
    with  DBGrid do
    begin
      Parent           := Page;
      Align            := alleft;
      AlignWithMargins := false;
      AllowDelete      := false;
      AllowInsert      := false;
      ColCount         := 8;
      Color            := clCream;
      Cursor           := crDefault;
      DataSource       := DM.ds_estoque;
      DragCursor       := crDrag;
      DragMode         := dmManual;
      Enabled          := True;
      Height           := 389;
      HelpContext      := 0;
      Left             := 0;
      Name             := 'dbcg_' + Grupo;
      Orientation      := goVertical;
      PanelBorder      := gbRaised;
      PanelHeight      := 97;
      PanelWidth       := 97;
      ParentColor      := False;
      ParentCustomHint := True;
      ParentFont       := True;
      ParentShowHint   := True;
      RowCount         := 4;
      SelectedColor    := clwhite;
      Showfocus        := True;
      TabOrder         := 0;
      TabStop          := True;
      Top              := 0;
      Visible          := True;
      Width            := 700;
      OnPaintPanel := dbcg_maisvendidosPaintPanel;
    end;
    DBGrid.ColCount:= 8;


    pnl_grid := TPanel.Create(DBGrid);
    with pnl_grid do
    begin
      Parent :=  DBGrid;
      Align := alclient;
      AutoSize := false;
      Alignment := taCenter;
      Ctl3D := True;
      UseDockManager := True;
      ParentBidiMode := True;
      Left := 0;
      Top := 0;
      Width := 97;
      Height := 97;
      Margins.Left := 5;
      Margins.Top := 5;
      Margins.Right := 5;
      Margins.Bottom := 5;
      Color := clRed;
      Padding.Left := 5;
      Padding.Top := 5;
      Padding.Right := 5;
      Padding.Bottom := 5;
      ParentBackground := False;
      TabOrder := 0;
      top := top + 97;
      left := left + 97;
    end;

    edt_codigo_item := TDBEdit.Create(pnl_grid);
    with edt_codigo_item do
    begin
      Parent := pnl_grid;
      Left := 9;
      Top := 118;
      Width := 27;
      Height := 29;
      DataField := 'CODIGO';
      DataSource := DM.ds_estoque;
      TabOrder := 2;
      Visible := False;
    end;
    edt_grupo := TDBEdit.Create(pnl_grid);
    with edt_codigo_item do
    begin
      Parent := pnl_grid;
      Left := 9;
      Top := 118;
      Width := 27;
      Height := 29;
      DataField := 'GRUPO';
      DataSource := DM.ds_estoque;
      TabOrder := 2;
      Visible := False;
    end;

    edt_descricao_item := TDBEdit.Create(pnl_grid);
    with edt_descricao_item do
    begin
      Parent := pnl_grid;
      Left := 6;
      Top := 6;
      Width := 85;
      Height := 25;
      Margins.Left := 10;
      Margins.Top := 10;
      Margins.Right := 10;
      Margins.Bottom := 10;
      Align := alTop;
      BorderStyle := bsNone;
      Color := clWhite;
      DataField := 'NOME';
      DataSource := DM.ds_estoque;
      Font.Charset := ANSI_CHARSET;
      Font.Color := clWindowText;
      Font.Height := -13;
      Font.Name := 'Segoe UI Semibold';
      Font.Style := [fsBold];
      MaxLength := 10;
      ParentFont := False;
      TabOrder := 1;
    end;

    DM.qr_grupos.Next;

结束;[enter image description here](https://i.stack.imgur.com/N4ZKV.jpg)

se eu crio a pagina em tempo de projeto funciona certo;

delphi-2010
© www.soinside.com 2019 - 2024. All rights reserved.