TChart versus Chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

TChart versus Chart

Post by Michal Blazejczyk » Tue Oct 10, 2006 1:32 pm

Hi,

Either I got confused or I'm overworked or something... :?

When I get an event from an Annotation object, I can query the Chart object from the Annotation object - but how do I get the matching TChart object???

Best,
Michal Blazejczyk
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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

Post by Narcís » Wed Oct 11, 2006 11:27 am

Hi Michal,

In v2 there is no way to find the 'container' of the chart class. For v3, IChart, which is internal in the v2 sources, has been public and you'll be able to do something like this:

Code: Select all

      IChart iChart = annotation1.Chart.Parent as IChart;
      IContainer container = iChart.GetContainer();.
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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Wed Oct 11, 2006 9:21 pm

Hi,

What I would like to know is how to get a TChart from a Chart:

Code: Select all

TChart tChart = annotation1.Chart.???;
Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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

Post by Narcís » Fri Oct 13, 2006 2:12 pm

Hi Michal,

This is not possible because annotation.Chart.Parent can be either a TChart or a WebChart. This is why IChart was published, IChart is an interface where TChart and WebChart inherit from. Once you get IChart you can obtain several properties as shown in the snippet above.
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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Mon Oct 16, 2006 3:48 pm

Hi,

OK, I see. But annotation.Chart.Parent doesn't exist. I guess it will be there in v3, right? And when it does, I should be able to cast annotation.Chart.Parent to TChart and that's it?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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

Post by Narcís » Tue Oct 17, 2006 10:35 am

Hi Michal,

Yes, for example this will work:

Code: Select all

      Annotation anno1 = new Annotation(tChart1.Chart);
      anno1.Text = "hello";

      IChart ichart = anno1.Chart.Parent;
      TChart tchart;
      if (ichart is TChart)
      {
        tchart = ichart as TChart;
        tchart.Header.Text = "hello";
      }
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

Post Reply