Calculate New Height Based On New Width?

c#

Solution

Algebra tells us it should be:

height = 400 * 240 / 500;

You can simplify this a bit by storing your aspect ratio

double ratio = 240 / 500;

// on resize
control.Height = (int)(control.Width * ratio);

Problem

I have a control whose width is 500 and height is 240, and I want to maintain the aspect ratio. The control's width gets resized to 400. What would the equation be the recalculate the new height? Chris

Original source