0

To understand what am i talking about, take a look at this video i recorded : https://youtu.be/JhRg1Iw2v2A

As you can see the PictureBox goes into the upper left corner when re-showing the pannel below the picture box and setting his size and anchors. The PictureBox don't autosize according to the form like before hidding the pannel below with the button

Here is my code :

        private void b_disable_Click(object sender, EventArgs e)
    {
        if (p_Bar.Visible == true)
        {
            p_Bar.Visible = false;
            pictureBox1.BringToFront();
            button1.BringToFront();
            pictureBox1.Dock = DockStyle.Fill;
        }
        else
        {
            p_Bar.Visible = true;
            pictureBox1.SendToBack();
            pictureBox1.Width = 784;
            pictureBox1.Height = 370;
            pictureBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);

        }
    }

I hope that someone can help me and if my problem is solved, can help others persons in need. Thx and have a good day if you read this !

Dièms
  • 5
  • 2
  • That's what you're asking it to do. Try with just: `p_Bar.Visible = !p_Bar.Visible;` in that Button.Click handler (comment out all the rest). – Jimi Aug 22 '21 at 05:25
  • I think you havn't understood my issue, have you watched the video ? (youtube link) also sorry for my english – Dièms Aug 22 '21 at 06:24
  • Your issue is that you set fixed dimensions to the PictureBox no matter whether the container Form is maximized or normalized. + `BringToFront()` and `SendToBack()` work the opposite way when it comes to docked Controls (or, it may *seem* like it). -- You don't need micro-management when the Control is docked (is it? If it's not, then Dock it in the Designer) -- Did you try what I suggested? – Jimi Aug 22 '21 at 06:54
  • okay its all good now – Dièms Aug 27 '21 at 11:07

0 Answers0