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 21-07-2007
Avatar de GerTorresM
GerTorresM GerTorresM is offline
Miembro
 
Registrado: nov 2005
Ubicación: Tunja - Boyacá
Posts: 210
Poder: 19
GerTorresM Va por buen camino
Unhappy Crear un DbGrid en una TTabSheet

Estoy intentando crear un DBGrid dentro una pestaña de un PageControl, para lo cual estoy empleando el siguiente código

Código Delphi [-]
 
PCInformacion:= TPageControl.Create(Self);
with PCInformacion do
begin
  Parent:= Form1; 
  Align:= AlClient;
end;
Hoja1:=TTabSheet.Create(PCInformacion);
with Hoja1 do
begin
  PageControl:= PCInformacion;
  Caption:= 'Hola Mundo';
  DTPFecha:= TDateTimePicker.Create(Self); 
  DBGDatos:= TDBGrid.Create(Self);
  DataSource:= TDataSource.Create(Self);
  DTPFecha.Parent:= Hoja1;
  DBGDatos.Parent:= Pagecontrol.Activepage;
end;

pero al intentar correr la apliación me envía el siguiente mensaje

Incompatibles types TWidgetControl And TTabSheet, al comentariar la línea donde fijo de parent del DBGrid, corre, pero no me dibuja el compnente, no se como puede remediar el error o cual sintaxis a emplear

Última edición por dec fecha: 21-07-2007 a las 02:01:19.
Responder Con Cita
  #2  
Antiguo 21-07-2007
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

¿De dónde se supone que sale "TWidgetControl"?
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #3  
Antiguo 21-07-2007
Avatar de ariefez
ariefez ariefez is offline
Miembro
 
Registrado: sep 2005
Ubicación: Perú - Lima
Posts: 63
Poder: 19
ariefez Va por buen camino
No se porque sale ese error pero ami si q me corre esa prsion de codigo, esta es la forma en la q corre

Código Delphi [-]
procedure TForm2.FormCreate(Sender: TObject);
var
  PCInformacion: TPageControl;
  Hoja1:TTabSheet;
begin
  PCInformacion:= TPageControl.Create(Self);
  with PCInformacion do
  begin
    Parent:= Self;
    Align:= AlClient;
  end;
  Hoja1:=TTabSheet.Create(PCInformacion);
  with Hoja1 do
  begin
    PageControl:= PCInformacion;
    Caption:= 'Hola Mundo';
    DBGDatos.Parent:= Hoja1;
  end;
end;


como no mencionas de q tipo es Hoja1 supuse q era TTabSheet
Responder Con Cita
  #4  
Antiguo 21-07-2007
Avatar de GerTorresM
GerTorresM GerTorresM is offline
Miembro
 
Registrado: nov 2005
Ubicación: Tunja - Boyacá
Posts: 210
Poder: 19
GerTorresM Va por buen camino
Unhappy Codigo Completo

Como tal vez o fui claro en la pregunta, me permito enviar la totalidad del código (no es muy largo por fortuna), y para mayor información estoy trabajando en Delphi 6 Enterprise.

el código es el siguiente

unit UFormulario;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QComCtrls,DB, ComCtrls, QDBGrids;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PCInformacion : TPageControl;
DTPFecha : TDateTimePicker;
Hoja1, Hoja2: TTabSheet;
DataSource : TDataSource;
DBGDatos: TDBGrid;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
PCInformacion:= TPageControl.Create(Self);
with PCInformacion do
begin
Parent:= Form1;
Align:= AlClient;
end;
Hoja1:=TTabSheet.Create(PCInformacion);
with Hoja1 do
begin
PageControl:= PCInformacion;
Caption:= 'Hola Mundo';
DTPFecha:= TDateTimePicker.Create(Self);
DBGDatos:= TDBGrid.Create(Self);
DataSource:= TDataSource.Create(Self);
DTPFecha.Parent:= Hoja1;
DBGDatos.Parent := Hoja1; // aqui es donde sale el error mencionado en la pregunta
end;
Hoja2:= TTabSheet.Create(PCInformacion);
with Hoja2 do
begin
PageControl:= PCInformacion;
Caption:= 'Hola Mundo en la Hoja 2';
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DTPFecha.Destroy;
Hoja1.Destroy;
Hoja2.Destroy;
PCInformacion.Destroy;
end;
end.

Gracías de antemano por su tiempo y colaboración
Responder Con Cita
  #5  
Antiguo 22-07-2007
Avatar de ariefez
ariefez ariefez is offline
Miembro
 
Registrado: sep 2005
Ubicación: Perú - Lima
Posts: 63
Poder: 19
ariefez Va por buen camino
Pues no le veo utilidad a las unidades QComCtrls, QDBGrids, o almenos a mi no me las reconoce , en vez de eso use ComCtrls, DBGrids y corre normal, te pego el codigo sin esas unidades. una cosa mas para liberar, se usa la rutina Free o FreeAndNil... un consejo al escribir tu mensaje resalta tu codigo con el boton Resaltar sintaxis delphi y quedara mas legible, suerte que existe Jedi Code Format, sino, no seria legible tu codigo.

Código Delphi [-]
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, DB, DBGrids;

type
  TForm2 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2:      TForm2;
  PCInformacion: TPageControl;
  DTPFecha:   TDateTimePicker;
  Hoja1, Hoja2: TTabSheet;
  DataSource: TDataSource;
  DBGDatos:   TDBGrid;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
  PCInformacion := TPageControl.Create(Self);
  with PCInformacion do
  begin
    Parent := Form2;
    Align  := AlClient;
  end;
  Hoja1 := TTabSheet.Create(PCInformacion);
  with Hoja1 do
  begin
    PageControl := PCInformacion;
    Caption     := 'Hola Mundo';
    DTPFecha    := TDateTimePicker.Create(Self);
    DBGDatos    := TDBGrid.Create(Self);
    DataSource  := TDataSource.Create(Self);
    DTPFecha.Parent := Hoja1;
    DBGDatos.Parent := Hoja1; // aqui es donde sale el error mencionado en la pregunta
  end;
  Hoja2 := TTabSheet.Create(PCInformacion);
  with Hoja2 do
  begin
    PageControl := PCInformacion;
    Caption     := 'Hola Mundo en la Hoja 2';
  end;
end;

procedure TForm2.FormDestroy(Sender: TObject);
begin
  DTPFecha.Free;
  Hoja1.Free;
  Hoja2.Free;
  PCInformacion.Free;
end;

end.

Una cosa mas al crear los controles, debes darles las coordenadas y dimensiones sino no los vaz a ver o van estar desordenados

Última edición por ariefez fecha: 22-07-2007 a las 16:12:38.
Responder Con Cita
  #6  
Antiguo 22-07-2007
Avatar de GerTorresM
GerTorresM GerTorresM is offline
Miembro
 
Registrado: nov 2005
Ubicación: Tunja - Boyacá
Posts: 210
Poder: 19
GerTorresM Va por buen camino
Smile Mejor Imposible

Les agradezco a todos su colaboración, me agrada muchisimo poder contar con gente con ustedes y con un sitio tan especilizado y organizado como el club.


Gracías
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
crear TTabSheet en tiempo de ejecucion Neiro Lazarus, FreePascal, Kylix, etc. 4 06-10-2006 23:03:08
TTabSheet - TForm - Parent neon OOP 0 11-01-2005 16:34:03
editor sencillo con pagecontrol y ttabsheet oesteve OOP 0 03-07-2003 10:36:47
como duplico intancias TtabSheet orfeo OOP 2 12-05-2003 04:15:04


La franja horaria es GMT +2. Ahora son las 17:03:38.


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