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

0

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

In this case, captcha images may have different sizes. So I'd like my Form to fit the size of the PictureBox. For example, if the image increases in size, the Form should match 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:

    
asked by anonymous 18.01.2017 / 18:20

1 answer

0

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

Size = new Size(novaLargura, novaAltura);
    
18.01.2017 / 18:35