Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Components Misc > Putting a dbgri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 191 of 240
Post > Topic >>

Putting a dbgrid and four bitbtns in one component

by hafezrabbani@[EMAIL PROTECTED] May 13, 2005 at 11:22 PM

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




 1 Posts in Topic:
Putting a dbgrid and four bitbtns in one component
hafezrabbani@[EMAIL PROTE  2005-05-13 23:22:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 18:43:32 CDT 2008.