mcmahling
asked on
Custom Component: Clearing the Component
I am using Delphi 2006 VCL. In the following code I am creating a component ScrollBox with a series of DBCharts. I have placed the component on a form. When the form opens the scrollbox is displaced with the DBCharts. The problem is that when I open the form again the DBCharts from the last time are persisting. In other words, if I called for 3 DBCharts before and closed the form then called for only two charts the second time, I will see the two new charts plus the third of the 3 charts I did the first time. How can I clear the scrollbox is the question?
unit MultiDBChart;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, DBChart;
type
TMultiDBChart = class(TScrollBox)
private
nOnClickChart : TNotifyevent;
procedure DoOnClick(Sender : TObject);
public
DBCharts : array of TDBChart;
function add : integer;
published
property OnClickChart: TNotifyEvent read nOnClickChart write nOnClickChart;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Additi onal', [TMultiDBChart]);
end;
procedure TMultiDBChart.DoOnClick(Se nder : TObject);
begin
nOnClickChart(sender);
end;
function TMultiDBChart.add : integer;
var
l : integer;
begin
l:=Length(DBCharts);
SetLength(DBCharts,l+1);
DBCharts[l]:=TDBChart.crea te(self);
with DBCharts[l] do
begin
parent := self;
onclick := DoOnClick;
//set width height and posittion of DBChart here.
end;
result := l
end;
end.
unit MultiDBChart;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, DBChart;
type
TMultiDBChart = class(TScrollBox)
private
nOnClickChart : TNotifyevent;
procedure DoOnClick(Sender : TObject);
public
DBCharts : array of TDBChart;
function add : integer;
published
property OnClickChart: TNotifyEvent read nOnClickChart write nOnClickChart;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Additi
end;
procedure TMultiDBChart.DoOnClick(Se
begin
nOnClickChart(sender);
end;
function TMultiDBChart.add : integer;
var
l : integer;
begin
l:=Length(DBCharts);
SetLength(DBCharts,l+1);
DBCharts[l]:=TDBChart.crea
with DBCharts[l] do
begin
parent := self;
onclick := DoOnClick;
//set width height and posittion of DBChart here.
end;
result := l
end;
end.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.