hafezrabbani@gmail.com Guest
|
Posted: Sat May 14, 2005 6:22 am Post subject: Putting a dbgrid and four bitbtns in one component |
|
|
Hi everybody!
I want to put a dbgrid and four BitBtns in a component, but I dont want
to put them in a frame because I want to encapsulte it better.
I know that I should creat a new package but I don't know what to do
then.
Maybe I should inherit the package class from TFrame and put dbgrid and
BitBtns on it, but when I want to put that component in a form, delphi
sends a message that It doesn't find components resource.
What should I do?
The source is here:
unit UnitGridset;
interface
uses
SysUtils, Classes, Controls, Grids, DBGrids, UnitTScrollDBGrid,
Buttons, Forms;
type
TGridSet = class(TCustomFrame)
private
{ Private declarations }
DBGrid:TScrollDbgrid;
BitBtnNext:TBitbtn;
BitBtnPrior:TBitbtn;
BitBtnFirst:TBitbtn;
BitBtnLast:TBitbtn;
protected
{ Protected declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;
public
{ Public declarations }
published
{ Published declarations }
property width;
property Height;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TGridSet]);
end;
{ TScrollDBGrid1 }
constructor TGridSet.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Parent:=(AOwner as TWinControl);
DBGrid:=TScrollDBGrid.Create(self);
DBGrid.Parent:=Self;
DBGrid.Top:=0;
DBGrid.Left:=0;
inherited Height:=320;
inherited width:=200;
DBGrid.Height:=inherited Height-35;
DBGrid.Width:=inherited Width;
BitBtnNext:=TBitBtn.Create(AOwner);
BitBtnPrior:=TBitBtn.Create(AOwner);
BitBtnFirst:=TBitBtn.Create(AOwner);
BitBtnLast:=TBitBtn.Create(AOwner);
BitBtnNext.Parent:=Self;
BitBtnPrior.Parent:=Self;
BitBtnFirst.Parent:=Self;
BitBtnLast.Parent:=Self;
BitBtnNext.Width:=30;
BitBtnPrior.Width:=30;
BitBtnFirst.Width:=30;
BitBtnLast.Width:=30;
BitBtnNext.Height:=30;
BitBtnPrior.Height:=30;
BitBtnFirst.Height:=30;
BitBtnLast.Height:=30;
BitBtnNext.Top:=inherited Top + inherited Height +10;
BitBtnPrior.Top:=inherited Top + inherited Height +10;
BitBtnFirst.Top:=inherited Top + inherited Height +10;
BitBtnLast.Top:=inherited Top + inherited Height +10;
BitBtnNext.Left:=inherited left + 10;
BitBtnPrior.Left:=inherited left + 45;
BitBtnFirst.Left:=inherited left + 80;
BitBtnLast.Left:=inherited left + 115;
BitBtnNext.BringToFront;
BitBtnPrior.BringToFront;
BitBtnFirst.BringToFront;
BitBtnLast.BringToFront;
end;
destructor TGridSet.Destroy;
begin
DBGrid.Destroy;
BitBtnNext.Destroy;
BitBtnPrior.Destroy;
BitBtnFirst.Destroy;
BitBtnLast.Destroy;
inherited ;
end;
end.
Thanks a lot for your help.
Hafez Rabbani
|
|