0

I have an application in C#, and I added one button to show and hide panel2, but when clicked the panel 2 is works perfect to showing and hide itself. but something wrong when click the button show/hide panel2 gives a quick black things, i don't know how to fix it.
this is my show/hide button syntax:

 if (Panel2.Visible == false) {
            Panel2.BackColor = Color.Transparent;
            Panel2.Visible = true;
            PictureBox2.Image = Properties.Resources.downmen;


        } else {
            Panel2.BackColor = Color.Transparent;
            Panel2.Visible = true;
            Panel2.Visible = false;
            PictureBox2.Image = Properties.Resources.upmen;
        }

this is my problem show:
enter image description here

Aso
  • 603
  • 7
  • 16
  • Enable double buffering on the form – Gusman Jun 09 '17 at 00:17
  • @Gusman, what does mean?, please enplane it. – Aso Jun 09 '17 at 00:20
  • https://learn.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-reduce-graphics-flicker-with-double-buffering-for-forms-and-controls – Gusman Jun 09 '17 at 00:21
  • Possible duplicate of [how to stop flickering C# winforms](https://stackoverflow.com/questions/8046560/how-to-stop-flickering-c-sharp-winforms) – Clint Jun 09 '17 at 00:39
  • While I've marked this as being a duplicate, if you're not too far into the project, I would recommend looking into using WPF or even UWP instead of winforms for a project this visually complex. – Clint Jun 09 '17 at 00:39
  • Try putting calls to `Panel2.SuspendLayout()` and `Panel2.ResumeLayout()` around your code so the panel doesn't repaint part way through updating its properties. – Bloopy Jun 09 '17 at 02:00

1 Answers1

0

May be too late for the answer. Set the default height and width (size) of Panel2 to 0. Set size of Panel2 based on the visibility of control