Aspect ratio

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
gille
Member
Member
Posts: 33
Joined: Fri Nov 27, 2009 11:11 pm

Aspect ratio
gille
Hello,

I want to resize my windows form, but it must keep the aspect ratio 16:9.
How can I do this?

Greetings,
gille
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Aspect ratio
Usman55
Well, the way I'd do it, would be to use the calculator and then multiply/divide both the numbers with a constant. For example, if I want to get the ratio of an A4 size paper in paint then I'd multiply the dimensions by 2 or 3 (210*297).
Image
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Aspect ratio
MrAksel
Code: Select all
Dim ratio As Double = 16 / 9
'To get the width: Width = ratio * Height'
'To get the Height: Height = Width / ratio'
I can't test it now since I'm on my iPod. When I get to my PC I can also give a better example.
Last edited by MrAksel on Tue Jun 12, 2012 12:21 pm, edited 1 time in total.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Ffenixw0rks
VIP - Donator
VIP - Donator
Posts: 152
Joined: Sun Jun 19, 2011 2:51 pm

Re: Aspect ratio
Ffenixw0rks
Your code will be:
Code: Select all
    Private Sub Form1_Resize(sender As System.Object, e As System.EventArgs) Handles MyBase.Resize
        
           Me.Width = Me.Height * 1.77
    End Sub
Or better way.

+REP if helped.
Image
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Aspect ratio
MrAksel
My code is the same as yours, you just calculated the 16/9 value :) The better way was I had in mind too, I just forgot to update my answer :lol: Great that you posted it
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
5 posts Page 1 of 1
Return to “Coding Help & Support”