Discussion:
Events from sub components in Property Editor
(too old to reply)
Glenn Shukster
2004-05-07 02:33:21 UTC
Permalink
Hi
I have a main component called MyGrid. One of its properties is MyRow
object that inherits from TPersistent. In the property editor of the
grid I can see MyRow and all its properties when I click the plus sign.
Unfortunatly, I don't see MyRow on the events side with all its events.
The events are published.
Do I have to inherit from something else to allow users to be able to
get at MyRow events from MyGrid?
--
Thanks
Glenn Shukster
Glenn Shukster
2004-05-08 04:59:55 UTC
Permalink
Hi
I still have not figured it out but wanted to send provice an example of a
component with this problem.
Now Even the EditRow RowNumber will not appear under properties.

unit component1;

interface

uses
SysUtils, Classes;

type
TEditRow = Class;

TRowBeforePostEvent = procedure(Sender: TEditRow; var AAccepted: boolean)
of object;

TEditRow = class(TPersistent)
private
FOnRowBeforePost: TRowBeforePostEvent;
FRowNumber: Integer;
protected
procedure DoRowBeforePost(Sender: TEditRow; var AAccepted: boolean);
virtual;
published
property RowNumber: Integer Read FRowNumber Write FRowNumber;
property OnRowBeforePost: TRowBeforePostEvent read FOnRowBeforePost
write FOnRowBeforePost;
end;

TTest = class(TComponent)
private
FEditRow: TEditRow;
FTestCnt: Integer;
published
Property TestCnt: Integer read FTestCnt write FTestCnt;
property EditRow: TEditRow read FEditRow write FEditRow;
end;

procedure Register;

implementation

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

{ TEditRow }

procedure TEditRow.DoRowBeforePost(Sender: TEditRow;
var AAccepted: boolean);
begin
If Assigned(OnRowBeforePost) then
OnRowBeforePost(Self,AAccepted);
end;

end.
--
Cheers
Glenn Shukster
Post by Glenn Shukster
Hi
I have a main component called MyGrid. One of its properties is MyRow
object that inherits from TPersistent. In the property editor of the
grid I can see MyRow and all its properties when I click the plus sign.
Unfortunatly, I don't see MyRow on the events side with all its events.
The events are published.
Do I have to inherit from something else to allow users to be able to
get at MyRow events from MyGrid?
--
Thanks
Glenn Shukster
Glenn Shukster
2004-05-08 14:28:14 UTC
Permalink
Still havn't figured it out but getting closer.
Looked at TLabeledEdit & TSimpleDataSet and changed my code to the
following.
The SubComponent shows in the editor properties but still not on the events
side.

unit component1;

interface

uses
SysUtils, Classes, Forms, stdctrls;

type
TRowBeforePostEvent = procedure(Sender: TObject; var AAccepted: boolean)
of object;

TEditRow = class(TComponent)
private
FOnRowBeforePost: TRowBeforePostEvent;
FRowNumber: Integer;
protected
procedure DoRowBeforePost(var AAccepted: boolean); virtual;
published
property RowNumber: Integer Read FRowNumber Write FRowNumber;
property OnRowBeforePost: TRowBeforePostEvent read FOnRowBeforePost
write FOnRowBeforePost;
end;

TTest = class(TComponent)
private
FEditRow: TEditRow;
FTestCnt: Integer;
public
Constructor Create(AOwner: TComponent); override;
published
Property TestCnt: Integer read FTestCnt write FTestCnt;
property EditRow: TEditRow read FEditRow;
end;

procedure Register;

implementation

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

{ TEditRow }

procedure TEditRow.DoRowBeforePost(var AAccepted: boolean);
begin
If Assigned(FOnRowBeforePost) then
FOnRowBeforePost(Self,AAccepted);
end;

{ TTest }

constructor TTest.Create(AOwner: TComponent);
begin
inherited; // Create(AOwner);
FEditRow := TEditRow.Create(Self);
FEditRow.Name := 'MyRow';
SetSubComponent(True);
end;

end.
--
Cheers
Glenn Shukster
Post by Glenn Shukster
Hi
I still have not figured it out but wanted to send provice an example of a
component with this problem.
Now Even the EditRow RowNumber will not appear under properties.
Post by Glenn Shukster
Hi
I have a main component called MyGrid. One of its properties is MyRow
object that inherits from TPersistent. In the property editor of the
grid I can see MyRow and all its properties when I click the plus sign.
Unfortunatly, I don't see MyRow on the events side with all its events.
The events are published.
Do I have to inherit from something else to allow users to be able to
get at MyRow events from MyGrid?
--
Thanks
Glenn Shukster
Glenn Shukster
2004-05-08 14:57:40 UTC
Permalink
Solved it. Guess I should have just kept going on my own.
The following line needed to be changed.
from just SetSubComponent(True);
to
FEditRow.SetSubComponent(True);
I put the corrected code below in case anyone else runs into the same
problem.

unit component1;

interface

uses
SysUtils, Classes;

type
TRowBeforePostEvent = procedure(Sender: TObject; var AAccepted: boolean)
of object;

TEditRow = class(TComponent)
private
FOnRowBeforePost: TRowBeforePostEvent;
FRowNumber: Integer;
protected
procedure DoRowBeforePost(var AAccepted: boolean); virtual;
published
property RowNumber: Integer Read FRowNumber Write FRowNumber;
property OnRowBeforePost: TRowBeforePostEvent read FOnRowBeforePost
write FOnRowBeforePost;
end;

TTest = class(TComponent)
private
FEditRow: TEditRow;
FTestCnt: Integer;
public
Constructor Create(AOwner: TComponent); override;
published
Property TestCnt: Integer read FTestCnt write FTestCnt;
property EditRow: TEditRow read FEditRow;
end;


procedure Register;

implementation

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

{ TEditRow }

procedure TEditRow.DoRowBeforePost(var AAccepted: boolean);
begin
If Assigned(FOnRowBeforePost) then
FOnRowBeforePost(Self,AAccepted);
end;

{ TTest }

constructor TTest.Create(AOwner: TComponent);
begin
inherited; // Create(AOwner);
FEditRow := TEditRow.Create(Self);
FEditRow.Name := 'MyRow';
FEditRow.SetSubComponent(True);
end;

end.
--
Cheers
Glenn Shukster

Loading...