Page 1 of 1

Axis.MaxLabelsWidth exception

Posted: Tue Oct 17, 2006 1:32 am
by 9790735
Hi,

I have upgraded to build 2.0.2469.25745. the Custom Axis placement is much better.

But I still get a problem with occasional exceptions from MaxLabelsWidth(). I have uploaded a sample project to steema.public.attachments.
Subect "Axis.MaxLabelsWidth exception"

run the form, click the button repeatedly. most of the time it is OK.
close the form, try again. repeat till you get an exception. It doesnt take long, usually the second run.
Once the exception occurs, it occurs every click. It really screws up my axis placement.

Any suggestions for a fix?

thanks,

Posted: Tue Oct 17, 2006 2:37 pm
by narcis
Hi matthbri,

Thanks for the project. We could reproduce the issue here and fixed it for the next releases. I've modified your project including a workaround. You'll find it attached in the newsgroups.

Posted: Tue Oct 17, 2006 4:41 pm
by 9790735
I guess the fix line is
BitMap bmp = tChart1.Bitmap;

I cannot do it this way in the actual application, as the Axes are not setup at load time, but change at runtime depending on the data.

Is the fix to use this line once only before a call to SetAxisPlacement()?
Or do I need to call it every time.

thanks,

Posted: Wed Oct 18, 2006 7:50 am
by narcis
Hi matthbri,
I guess the fix line is
BitMap bmp = tChart1.Bitmap;
Yes, this forces the chart being internally painted so that when SetAxisPlacement() is called in the OnLoad event all objects used there have valid values.
I cannot do it this way in the actual application, as the Axes are not setup at load time, but change at runtime depending on the data.

Is the fix to use this line once only before a call to SetAxisPlacement()?
Or do I need to call it every time.


In fact, the Bitmap trick is not absolutelly necessary, as you can see in the example I posted, just wrapping the SetAxisPlacement() content with a try-catch block prevents the exception rising and the application keeps working fine.