Ver Mensaje Individual
  #8  
Antiguo 19-10-2022
steelha steelha is offline
Miembro
 
Registrado: mar 2012
Posts: 158
Reputación: 13
steelha Va por buen camino
Muchas gracias, he podido resolver el problema aca dejo código completo. Si lo ven feíto y quieren aportar algo para que se vea mejor estéticamente y mejorar rendimiento sean bienvenidos XD. Ahora me toca la parte dolorosa guardar la información de cada uno en su respectivos lugar y luego cargarla para consultar T_T (siento que me va a doler la cabeza pero tengo a mano aspirina XD).

Código Delphi [-]
procedure TfrmPacientes.Crear_panel();
Var
 LPanel   : TCategoryPanel;
 Cat      : TCategoryButtons;
 npaneles : Integer;
 but      : TButtonItem;
 i, j     : Integer;
 edt      : TEdit;
 mem      : TMemo;
 chk      : TCheckBox;
 lbl      : TLabel;
 contcomp : Integer;
 tp       : Integer;
 sumaalt  : Integer;
Const
  cl = 165;  //Los controles estaran siempre en la left 165
  ll = 5;    //Los label estaran siempre en la pos left 5
  sp = 5;    //Separacion etre controles

  lw = 154;
  ew = 160;  eh = 21;
  mw = 510;  mh = 90;
  cw = 25;   ch = 17;
begin
  DM.QryPGrupos.Close;
  DM.QryPGrupos.Parameters.ParamByName('p').Value := DM.QryPlantillaDefaultidPlantilla.Value;
  DM.QryPGrupos.Open;
  npaneles := DM.QryPGrupos.RecordCount;

  contcomp := frmPacientes.ComponentCount;

  for i := 1 to npaneles do
  begin
      LPanel:=TCategoryPanel.Create(micategorygroup);
      LPanel.Caption:= Trim(DM.QryPGrupos.FieldByName('DatosCaptionGrupo').AsString);
      LPanel.PanelGroup:= micategorygroup;
      LPanel.TabOrder  := i;
      LPanel.Name := Trim('Grupo' + i.ToString);

      Cat := TCategoryButtons.Create(lPanel);
      Cat.Name := 'Category' + i.ToString;
      cat.Parent := LPanel;
      Cat.Align := alClient;
      cat.ButtonWidth := 675;

      DM.QryPButtons.Close;
      DM.QryPButtons.Parameters.ParamByName('p').Value   := DM.QryPlantillaDefaultidPlantilla.Value;
      DM.QryPButtons.Parameters.ParamByName('cap').Value := DM.QryPGrupos.FieldByName('DatosCaptionGrupo').AsString;;
      DM.QryPButtons.Open;

      LPanel.Height := (50 * (DM.QryPButtons.RecordCount));
      tp := 2; //Posicion inicial del primer control

      //Para calcular la altura del proximo control se utilizara
      //tp = tp + alturadelcontrol + sp;
      //Donde tp es el top actual y sp es la separacion entre controles

      // Para cada Grupo, crear los botones...
      for j := 0 to (DM.QryPButtons.RecordCount -1) do
      begin
          contcomp := contcomp + 1;
          //Crear el label con la nota del campo a introducir dato
          lbl       := TLabel.Create(Self);
          lbl.Name  := 'lbl'+IntToStr(contcomp);
          lbl.Parent:= Cat;
          lbl.Caption:= Trim(DM.QryPButtonsDatosDetalle.Value);
          lbl.Top   := tp;
          lbl.Left  := ll;

        // Crear el control segun su tipo y ubicarlo al lado del label
        if (Trim(DM.QryPButtonsDatosTipo.Value) = 'TEdit') Or (Trim(DM.QryPButtonsDatosTipo.Value) = 'Edit') then
        begin
          edt       := TEdit.Create(Self);
          edt.Name  := 'Edt'+IntToStr(contcomp);
          edt.Parent:= Cat;
          edt.Tag   := DM.QryPButtonsidDatos.Value;
          edt.Width := ew;
          edt.Text  := '';
          edt.Top   := tp;
          edt.Left  := cl;

          tp := tp + eh + sp;
        end;

        if (Trim(DM.QryPButtonsDatosTipo.Value) = 'TMemo') Or (Trim(DM.QryPButtonsDatosTipo.Value) = 'Memo') then
        begin
          mem       := TMemo.Create(Self);
          mem.Name  := 'Mem'+IntToStr(contcomp);
          mem.Parent:= Cat;
          mem.Tag   := DM.QryPButtonsidDatos.Value;
          mem.Width := mw;
          mem.Text  := '';
          mem.Top   := tp;
          mem.Left  := cl;

          tp := tp + mh + sp;
        end;

        if (Trim(DM.QryPButtonsDatosTipo.Value) = 'TCheckbox') Or (Trim(DM.QryPButtonsDatosTipo.Value) = 'Checkbox') then
        begin
          chk       := TCheckBox.Create(Self);
          chk.Name  := 'Chk'+IntToStr(contcomp);
          chk.Parent:= Cat;
          chk.Tag   := DM.QryPButtonsidDatos.Value;
          chk.Width := cw;
          chk.Caption:='';
          chk.Top   := tp;
          chk.Left  := cl;

          tp := tp + ch + sp;
        end;

        //but := TButtonItem.Create(Cat.Categories.Add.Items);
        //but.Caption := DM.QryPButtons.FieldByName('DatosDetalle').AsString;

        DM.QryPButtons.Next;
      end;
      //Reajustar altura del panel
      LPanel.Height := tp + 25;

      DM.QryPGrupos.Next;
  end;
end;
Responder Con Cita