[DrawLines] How to delete one line ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

[DrawLines] How to delete one line ?

Post by bertrod » Mon Feb 20, 2006 10:24 am

The question is the the subject : when I draw many lines with the drawlines tool, is it possible to delete juste one line ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Feb 20, 2006 10:42 am

Hi bertrod,

Yes, you could use something like the code below. This snippet removes the first drawn line.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  ChartTool1.Lines[0].Destroy;
  Chart1.Refresh;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Mon Feb 20, 2006 10:50 am

Thanks.

But now how to know on which line the user has clicked ? (I would like to enable a right-click on a line to delete it).

I see that the TDrawLine has a property ID and Index, do you think I can use one of them to identify a line ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Feb 20, 2006 11:45 am

Hi bertrod,

Yes, you can use something like:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   if ((ChartTool1.Clicked(X,Y) <> nil) and not ChartTool1.EnableDraw) then
  begin
    ChartTool1.Clicked(X,Y).Destroy;
    Chart1.Refresh;
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Mon Feb 20, 2006 12:12 pm

Great, thanks for your help :D

Post Reply