Ver Mensaje Individual
  #1  
Antiguo 11-03-2023
juank1971 juank1971 is offline
Miembro
 
Registrado: feb 2008
Posts: 230
Reputación: 17
juank1971 Va por buen camino
componente TstringGrid con panel de propiedades

Hola quisiera hacer un componente que herede de TstringGrid, y arriba de este poner un panel o varios con algunas propiedades visuales para cambiar colores tipos de letras, filtrar, etc, pero no logro crear un componente que cree otro componente en el constructor.

Esta es la unit que tengo muy básica a ver si me ayudan quisiera que crear un Trectangle en el padre de el grid, y ponerlo en el top , como casi siempre tengo los grids en un contenedor TTabItem y este rectángulo quisiera saliera arriba del grid por tanto tendría el mismo padre que el grid.

A lo mejor surge otra idea, lo que si quisiera es crear un componente TstrinGrid, con paneles para propiedades y de ser posibles varios , por ejemplo un panel o Rectangulo para filtrar, otro para configurar columnas, otro para configurar tipos de letras tamaños y colores etc.

Código Delphi [-]
unit StringGridMy;

interface

uses
  System.SysUtils, System.Classes, FMX.Types, FMX.Controls,
  FMX.Controls.Presentation, FMX.ScrollBox, FMX.Grid,FMX.Objects,FMX.Grid.Style,FMX.Presentation.Factory,FMX.Presentation.Style,
  FMX.Layouts, System.UITypes,FMX.Graphics,FMX.StdCtrls;

type

  TStringGridMy= class(TStringGrid)
  private
    vRectMain: TRectangle;
  protected
    { Protected declarations }
  public
     property RectMain: TRectangle read vRectMain write vRectMain;
    constructor Create(AOwner: TComponent); override;
  published
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('ComponenteMy', [TStringGridMy]);
end;



constructor TStringGridMy.Create(AOwner: TComponent);
begin
  inherited  Create(AOwner);
  Height := 480;
  Width := 640;
 
 
    vRectMain := TRectangle.Create(self.parent);//aqui quisiera viera el padre del grid
    vRectMain.Parent := self.parent;
    vRectMain.Align := TAlignLayout.top;
    vRectMain.Width := Self.Width;
    vRectMain.Height := 50;
    vRectMain.bringtofront;
    vRectMain.Fill.Color := TAlphaColorRec.White;
    vRectMain.Fill.Kind := TBrushKind.Solid;
 

end;


initialization
  TPresentationProxyFactory.Current.Register(TStringGridMy, TControlType.Styled, TStyledPresentationProxy);

finalization
  TPresentationProxyFactory.Current.Unregister(TStringGridMy, TControlType.Styled, TStyledPresentationProxy);

históricamente hablando se que nunca he logrado entender bien a fondo el orden de construir y destruir los objetos en DELPHI, creo que por no entender bien esto he pasado tanto trabajo con la creación de los controles o componentes durante muchos años jeje.
Responder Con Cita