Hi,
I would like to be able to re-size a picturebox at run time, so that it stays in proportion with the rest of the form if the user changes the size of the form.
I would've thought this would do the trick but it doesn't. Watching it in De-Bug it all works correctly, except the dimensions of the pic'box don't change. Mw and Mh are global integer variables, set on initialisation to Me.Width and Me.Height respectively, and F is a global Boolean, initially 'True' re-set after initialisation.
Had this worked in the first trial, (or a subsequent one) I'd've changed "If a > b" to "If a > 1 And a > b" to get the largest pic'box which ever direction of change.
I might've also tried e.g. "PictureBox1.Width *= a"
Poppa.
I would like to be able to re-size a picturebox at run time, so that it stays in proportion with the rest of the form if the user changes the size of the form.
vb.net Code:
Private Sub Form1_SizeChanged(sender As System.Object, e As System.EventArgs) Handles MyBase.SizeChanged Dim a, b As Double If F Then Exit Sub a = Me.Width / Mw 'Change of width as multiple of size. b = Me.Height / Mh 'Change of height as multiple of size. If a > b Then 'Change PictureBox1 by lesser multiple to maintain ratio. PictureBox1.Width = PictureBox1.Width * b PictureBox1.Height = PictureBox1.Height * b Else PictureBox1.Width = PictureBox1.Width * a PictureBox1.Height = PictureBox1.Height * a End If End Sub
Had this worked in the first trial, (or a subsequent one) I'd've changed "If a > b" to "If a > 1 And a > b" to get the largest pic'box which ever direction of change.
I might've also tried e.g. "PictureBox1.Width *= a"
Poppa.