How to adjust the Form according to the size of the Picturebox?

Asked

Viewed 477 times

0

How do I resize my form according to the size of the Picturebox component?

In this case, the images in the Boxes may have different sizes. So I would like my Form to fit the size of the Picturebox. For example, if the image increases in size, the Form should follow its size.

Here I change the size of the Picturebox, but the Form does not resize.

public ResolverCaptcha(Bitmap imagemCaptcha, string mensagem)
    {
        InitializeComponent();
        lblMensagem.Text = mensagem;
        pctCaptcha.Width = imagemCaptcha.Width;
        pctCaptcha.Height = imagemCaptcha.Height;
        pctCaptcha.Image = imagemCaptcha;
    }

This is the Form:

Form que desejo redimensionar.

  • Your problem is changing the size of the form or knowing how much you need to increase? Or both?

  • @jbueno Change the size of the Form! Is there any configuration in the Form properties to fit the size of the components or really have to change the size "in the hand"?

  • @Lucasalcântara how is the image loaded? it’s all in the hand!!!

1 answer

0


It is necessary to change the size of the form "at hand". It will not resize itself.

Size = new Size(novaLargura, novaAltura);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.