Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
How can I get the size of a Chart before it's drawn?

Edit: I'm using VB.NET in Visual Studio 2019

I have a chart on a modal form with a single ChartArea that displays a line graph. I need the axes of the chart to be scaled 1:1 relative to each other. In other words, no distortion/stretch. I need the the same number of pixels-per-unit on each axis.

I'm able to get the charts axes min and max values (and use an algorithm to force them to be "pretty") numbers. So all I need to do is set the size of the plotted area in pixels based on the ratio of the axes value ranges.

I know the size of the plotted area is dependent on the ChartArea.Position and ChartArea.InnerPlotPosition size properties (which are 0 - 100 values that describe their percentage size relative to their containers). The problem is this: When I poll these properties during the form load, they both come up as zero. The chart displays the data and everything works, I'm just not able to resize it as I want to during load because these size values are apparently not set yet.

If I close the modal form and launch it again, then the properties populate with non-zero values. But I really need it to work the first time.

I've tried using .Refresh(), .Invalidate, and .PerformLayout() on both the Chart and the Form during the load event. I've also tried programmatically launching the form twice in rapid succession. I've tried moving the check of those properties to a subroutine that runs at the end of the form load. Nothing works.

Is there any way to know those size percentages during the load event? Thank you for your help.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!