Page 1 of 1

PageNumTool and event

Posted: Mon Jan 24, 2011 5:09 pm
by 10050873
Hello,

I am looking for an event on the TPageNumTool in order to change the chart title when the number of page change.
I have tested with the event on click but it is not fired when the page change only when we click on the tool

Thanks for help

Regards

Re: PageNumTool and event

Posted: Tue Jan 25, 2011 9:38 am
by yeray
Hi Calou,

There is not a public event for the tool but there is an event for the chart pages, the OnPageChange event. You can use assign it at design time or at runtime as follows:

Code: Select all

procedure Chart1PageChange(Sender: TObject);
//...
uses Series, TeePageNumTool;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TBarSeries) do FillSampleValues(25);

  Chart1.Tools.Add(TPageNumTool);

  Chart1.Pages.MaxPointsPerPage:=5;

  Chart1.OnPageChange:=Chart1PageChange;
end;

procedure TForm1.Chart1PageChange(Sender: TObject);
begin
  Chart1.Title.Text.Text:=IntToStr(Chart1.Pages.Current);
end;

Re: PageNumTool and event

Posted: Tue Jan 25, 2011 11:39 am
by 10050873
Thanks