Board index » delphi » Component Creation Problem

Component Creation Problem


2003-08-14 11:27:13 AM
delphi163
Hi All,
Find below my code for a component I am trying to create. What I want is a
TPanel with Components already created on it with functionality already in
place.
What I do it put 2 x TAdvstringrids on the TPanel one containing all of the
stores and transfer from one grid to another. My problem is working out the
functionality but working out how to create a TAdvstringrid on the TPanel. I
hope this makes sense
Thanks in Advance
Aaron
//BEGINING OF COMPONENT
unit A7StoreSelection;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, AdvGrid;
type
TA7StoreSelection = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
public
List: TAdvStringGrid;
constructor Create(AOwner: TComponent); override;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
constructor TA7StoreSelection.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 441;
Height := 305;
Caption := ' ';
with List do
begin
List := TAdvStringGrid.Create(AOwner); // This is where my problem
begins. Have trired Self instead of Aowner but didn't work and I am outta
ideas.
Left := 16;
Top := 40;
Width := 169;
Height := 233;
Cursor := crDefault;
ColCount := 4;
DefaultRowHeight := 21;
FixedCols := 0;
RowCount := 2;
FixedRows := 1;
end;
end;
procedure Register;
begin
RegisterComponents('A7', [TA7StoreSelection]);
end;
end.
 
 

Re:Component Creation Problem

Hi AAron,
You're almost there, just add
List.parent := self;
after List := TAdvStringGrid.Create(AOwner);
HTH,
Dirk Naudts.
"Aaron Miles" <XXXX@XXXXX.COM>writes
Quote
Hi All,

Find below my code for a component I am trying to create. What I want is a
TPanel with Components already created on it with functionality already in
place.

What I do it put 2 x TAdvstringrids on the TPanel one containing all of
the
stores and transfer from one grid to another. My problem is working out
the
functionality but working out how to create a TAdvstringrid on the TPanel.
I
hope this makes sense

Thanks in Advance

Aaron


//BEGINING OF COMPONENT
unit A7StoreSelection;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, AdvGrid;

type
TA7StoreSelection = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
public
List: TAdvStringGrid;
constructor Create(AOwner: TComponent); override;
{ Public declarations }
published
{ Published declarations }
end;

procedure Register;

implementation

constructor TA7StoreSelection.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 441;
Height := 305;
Caption := ' ';
with List do
begin
List := TAdvStringGrid.Create(AOwner); // This is where my problem
begins. Have trired Self instead of Aowner but didn't work and I am outta
ideas.
Left := 16;
Top := 40;
Width := 169;
Height := 233;
Cursor := crDefault;
ColCount := 4;
DefaultRowHeight := 21;
FixedCols := 0;
RowCount := 2;
FixedRows := 1;
end;
end;

procedure Register;
begin
RegisterComponents('A7', [TA7StoreSelection]);
end;

end.


 

Re:Component Creation Problem

Hi Aaron!
"Aaron Miles" <XXXX@XXXXX.COM>píše v diskusním
příspěvku news:3f3b0185$XXXX@XXXXX.COM...
Quote
What I do it put 2 x TAdvstringrids on the TPanel one containing all of
the
stores and transfer from one grid to another. My problem is working out
the
functionality but working out how to create a TAdvstringrid on the TPanel.
I
hope this makes sense
Here is my version (I have used standard TStringGrid in this example since I
do not own the Adv version of the control):
// begin code snippet
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, Grids;
type
TA7StoreSelection = class(TPanel)
private
FGrid: TStringGrid;
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Grid: TStringGrid read FGrid;
end;
procedure Register;
implementation
constructor TA7StoreSelection.Create(AOwner: TComponent);
begin
inherited;
Width := 441;
Height := 305;
Caption := ' ';
// Use "Self" as an owner since you (TA7StoreSelection) is responsible
// for maintaining the lifetime of this grid.
FGrid := TStringGrid.Create(Self);
with FGrid do
begin
Left := 16;
Top := 40;
Width := 169;
Height := 233;
Cursor := crDefault;
ColCount := 4;
DefaultRowHeight := 21;
FixedCols := 0;
RowCount := 2;
FixedRows := 1;
// Make the grid a child of this panel.
Parent := Self;
Visible := True;
end;
end;
destructor TA7StoreSelection.Destroy;
begin
FGrid.Free;
inherited;
end;
procedure Register;
begin
RegisterComponents('A7', [TA7StoreSelection]);
end;
end.
// end code snippet
Best regards,
Ivo