Home > Software engineering >  I want the image in the PICTUREBOX to change with the size of the FORM. What should I do?
I want the image in the PICTUREBOX to change with the size of the FORM. What should I do?

Time:10-06

Private Sub Form sample 2 _resize (ByVal sender As Object, ByVal e the As System. EventArgs) Handles Me. Resize

PictureBox1. Height=Me. Height - 20
PictureBox1. Width=Me. Width - 20

Dim GRFX As Graphics=PictureBox1. CreateGraphics
GRFX. DrawImage (img, 0, 0, PictureBox1 Width, PictureBox1. Height)
End Sub

RT, the code above basic I realize the problem in the title, but also, there is a problem, I can't solve: when the FORM to maximize operating, image cannot display completely, can only display part of the great spirit show rookie,
The same code is written in the ResizeEnd, Paint, MaximumSizeChanged couldn't find a solution,
The user can't operate the mouse,

CodePudding user response:

Try using graphics,

CodePudding user response:

As a property, you can set the image adaptive, picture box size, Picture1. AutoSize=True
Or,
PictureBox1. Height=Me. Height - 20
PictureBox1. Width=Me. Width - 20
This below, also add
Picture of high=PictureBox1. The Height - 10
Picture of high=PictureBox1. The Widtht - 10

Try it, their estimates, not testing

CodePudding user response:

Images load when running the process
Private Sub Piclogo_Resize ()
If Piclogo=0 Then the Exit Sub
Piclogo. PaintPicture Piclogo, Piclogo ScaleLeft, Piclogo. ScaleTop, Piclogo. ScaleWidth, Piclogo. ScaleHeight
DoEvents
End Sub
  • Related