Page 1 of 1

Set Axis and Zoom in Form Load Wonky

Posted: Sun Jul 31, 2022 8:00 am
by 13049545
Hi Steema -
I'm building an app and trying to set the TChart Axes and Zoom during form Load -
The Set Axes works but not the Zoom -
But if I set the Axes and Zoom with the same code from buttons on the form once loaded it works.

I'm sure it's an event sequencing issue of some sort but can't figure it out.

I distilled the problem reproducing code into a simple one-page c# .net WinForms app to see if it's solvable.

I've also attached some screenshots.

Thanks so much for your help!

Joseph
I only attached the form1 c# code because I couldn't attach the solution rar because it was too large. But if you need the VS2019 Solution ping me.

Re: Set Axis and Zoom in Form Load Wonky

Posted: Mon Aug 01, 2022 3:36 pm
by Marc
Hello,

The chart needs to render before it can run the zoom on what would be the rendered dimensions. You could achieve that this way, removing the call to SetZoom from the initialisation code and adding a one-time call in the Chart OnAfterdraw event:

Code: Select all

        bool hasLoaded = false;
        private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.IGraphics3D g)
        {

            if (!hasLoaded)
            {
                hasLoaded = true;
                SetZoom();
            }

        }
Regards,
Marc Meumann

Re: Set Axis and Zoom in Form Load Wonky

Posted: Mon Aug 01, 2022 3:57 pm
by 13049545
I will give this a try. Thanks very much Marc!

Re: Set Axis and Zoom in Form Load Wonky

Posted: Wed Aug 03, 2022 6:17 pm
by 13049545
Hi Marc,
I tried the AfterDraw code change you suggested and the Zoom still doesn't work. I tried messing around a little bit with UndoZoom first and DoEvents but still no Zoom using AfterDraw.

I've attached my code in case that's helpful and have the whole VS 2019 Project with just the repro code if it's helpful as well.

Thanks,
Joseph
MovedZoomToAfterDraw.jpg
MovedZoomToAfterDraw.jpg (110.19 KiB) Viewed 4276 times