Which Object is Clicked

I have a program written in Delphi 2005 VCL. I have code that puts multiple DBCharts on a page based on a users select.  I need to know what DBChart a user clicks on to determine if there is additional inforamtion I can displace for the DBChart.  How can I determine which DBChart the user has clicked on?
mcmahlingAsked:
Who is Participating?
 
Ivanov_GConnect With a Mentor Commented:
Inside your form define something like this:

  TForm1 = class(TForm)
  ...
  private
    procedure DBChartClick(Sender: TObject);
  public
  end;

procedure TForm1.DBChartClick(Sender: TObject);
begin
  if Sender is TDBChart then
    begin
      ShowMessage((Sender as TDBChart).Name);
    end;
end;

------------------------------------------------

Then after you create the TDBCharts add something like this:

  DBChart1.OnClick := DBChartClick;
  DBChart2.OnClick := DBChartClick;
  DBChart3.OnClick := DBChartClick;

Now when you click a DBChart you will see its name.
0
All Courses

From novice to tech pro — start learning today.