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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivanov_GCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.