ColorBand tool code issue

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

ColorBand tool code issue

Post by Mike Jones » Thu Apr 17, 2008 6:33 pm

Found in the TeeChart for .NET [04 APR 2008] RELEASE 3.2.3016.15520/1/2

That the code for the ColorBand tool had been modified. The change caused my code to throw an Null Reference exception at run time. The fix was pretty straight forward but I thought I would share it in case anyone else ran across the same problem.

My old code that worked fine prior to this latest release looked like:

Code: Select all

ColorBand colorband = new ColorBand();
colorband.Axis = tChart1.Axes.Left;
colorband.Brush.Color = System.Drawing.Color.Red;
colorband.Brush.Solid = true;
colorband.DrawBehind = true;
colorband.End = 300;
colorband.ResizeEnd = false;
colorband.ResizeStart = false;
colorband.Start = 250;
colorband.Pen.Visible = false;  // hides the edge lines
colorband.Transparency = 50;
tChart1.Tools.Add(colorband);
The above code would throw the Null Reference Exception when trying to assign to the ColorBand.Axis property.

The fix was to make sure the Chart property is set either by doing it in the constructor of the ColorBand or via the ColorBand.Chart property.

So the fix looked like this:

Code: Select all

ColorBand colorband = new ColorBand(tChart1.Chart;);  // <- changed line
colorband.Axis = tChart1.Axes.Left;
colorband.Brush.Color = System.Drawing.Color.Red;
colorband.Brush.Solid = true;
colorband.DrawBehind = true;
colorband.End = 300;
colorband.ResizeEnd = false;
colorband.ResizeStart = false;
colorband.Start = 250;
colorband.Pen.Visible = false;  // hides the edge lines
colorband.Transparency = 50;
tChart1.Tools.Add(colorband);

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 Apr 18, 2008 7:46 am

Hi Mike,

Thanks for reporting the issue. I could reproduce it and added the defect (TF02012981) to our bug list to be fixed for next releases.
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

AndreasL
Newbie
Newbie
Posts: 8
Joined: Wed May 23, 2007 12:00 am
Contact:

Post by AndreasL » Fri Sep 05, 2008 2:30 pm

Hello,

when will this issue be fixed ? I have every update problems with this.

Best regards

Andreas Lindenthal

Post Reply