Page 1 of 1

ColorBand tool code issue

Posted: Thu Apr 17, 2008 6:33 pm
by 8739068
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);

Posted: Fri Apr 18, 2008 7:46 am
by narcis
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.

Posted: Fri Sep 05, 2008 2:30 pm
by 13045133
Hello,

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

Best regards

Andreas Lindenthal