Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-03-2023
juank1971 juank1971 is offline
Miembro
 
Registrado: feb 2008
Posts: 230
Poder: 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
  #2  
Antiguo 12-03-2023
juank1971 juank1971 is offline
Miembro
 
Registrado: feb 2008
Posts: 230
Poder: 17
juank1971 Va por buen camino
buscando ayuda he seguido este link
de embarcadero https://docwiki.embarcadero.com/RADS...onent_(Delphi)

Y Aunque puedo con este enlace lo que quiero visualmente que es un componente que contenga un grid y un rectangulo arriba, pero no puedo ver las propiedades de los mismos , del grid ni del rectangulo.

seria bueno esto mismo para contener varios componentes en uno ,pero mostrando todas las propiedades de cada cual, para poder enlazarlas en tiempo de diseño
Responder Con Cita
  #3  
Antiguo 14-03-2023
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Yo en este caso (y tal vez me equivoco) optaría por deribar no de un TStringGrid, sino de un componente que te sirve de contenedor de ambos, por ejemplo un TRectangle o un TPanel.
Otra opción es generar un Frame con lo que necesitas y reaprovecharlo. Tal vez esta opción sea más sencilla si no estás "muy puesto" en el tema de diseño de componentes de FMX (que no es igual que en VCL).

Una prueba rápida:

Código Delphi [-]
unit uStringGridProps;

interface

uses
  System.SysUtils, System.Classes, FMX.Types, FMX.Controls, FMX.Objects, FMX.Grid,
  FMX.Grid.Style,FMX.Presentation.Factory,FMX.Presentation.Style;

type
  TStringGridProps = class(TRectangle)
  private
    stGrid: TStringGrid;
    RecProps, RecFiltro: TRectangle;
    FVisibleGrid: boolean;
    FVisibleProps: boolean;
    FVisibleFiltro: boolean;
    procedure SetVisibleFiltro(const Value: boolean);
    procedure SetVisibleProps(const Value: boolean);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Grid:TStringGrid read stGrid write stGrid;
    property VisibleGrid:boolean read FVisibleGrid;
    property VisibleProps:boolean read FVisibleProps write SetVisibleProps;
    property VisibleFiltro:boolean read FVisibleFiltro write SetVisibleFiltro;
  end;

procedure Register;

implementation

uses
  System.UITypes;

procedure Register;
begin
  RegisterComponents('Samples', [TStringGridProps]);
end;

{ TStringGridProps }

constructor TStringGridProps.Create(AOwner: TComponent);
begin
  inherited Create(Owner);

  // valores por defecto
  FVisibleGrid := True;
  FVisibleProps := False;
  FVisibleFiltro := False;


    // StringGrid
    stGrid := TStringGrid.Create(Self.Parent);
    stGrid.Name := 'stGrig';
    stGrid.Parent := Self.Parent;
    stGrid.Align := TAlignLayout.Client;
    // Rectangulo de prppiedades
    RecProps := TRectangle.Create(Self.Parent);
    RecProps.Name := 'RecProps';
    RecProps.Parent := Self.Parent;
    RecProps.Align := TAlignLayout.Top;
    // RecBtFirst.Stroke.Kind := Stroke.Kind.bkNone;
    RecProps.fill.Color := TAlphaColorRec.Darkgray;
    RecProps.Height := 80;
    RecProps.Tag := 1;
    // Rectangulo de filtro
    RecFiltro := TRectangle.Create(Self.Parent);
    RecFiltro.Name := 'RecFiltro';
    RecFiltro.Parent := Self.Parent;
    RecFiltro.Align := TAlignLayout.Top;
    // RecBtFirst.Stroke.Kind := Stroke.Kind.bkNone;
    RecFiltro.fill.Color := TAlphaColorRec.Darkgray;
    RecFiltro.Height := 80;
    RecFiltro.Tag := 1;

  Self.Repaint;

end;

destructor TStringGridProps.Destroy;
begin

  inherited;
end;


procedure TStringGridProps.SetVisibleFiltro(const Value: boolean);
begin
  FVisibleFiltro := Value;
  RecFiltro.Visible := FVisibleFiltro;
  Repaint;
end;

procedure TStringGridProps.SetVisibleProps(const Value: boolean);
begin
  FVisibleProps := Value;
  RecFiltro.Visible := FVisibleProps;
  Repaint;
end;

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

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

end.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #4  
Antiguo 14-03-2023
juank1971 juank1971 is offline
Miembro
 
Registrado: feb 2008
Posts: 230
Poder: 17
juank1971 Va por buen camino
gracias voy probando
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Instalar componente ADVSmooth panel maxi915 Varios 1 21-10-2013 11:49:10
Que componente descendiente de TStringGrid me recomiendan?? DANY OOP 12 02-12-2010 22:30:02
Busco componente panel con pestañas Er0s Varios 1 14-09-2010 14:17:16
Componente que sea un panel con chincheta??? vejerf OOP 9 20-05-2008 10:45:42
Borrar fila seleccionada de un componente TStringGrid JM75 OOP 3 16-11-2006 10:31:06


La franja horaria es GMT +2. Ahora son las 16:11:12.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi