2

I am working on a personal project. At one point in the project you have a menu with some buttons, and one of those buttons will:

  1. Hide current form
  2. Create a second form and show it through ShowDialog(this)
  3. When the second form closes, the first form will be shown again with Show()

My issue is, that after showing the first form again, a certain border is not being redrawn. The object with this border is called pnlInfoBoard.

Here is some screenshots to show the problem: enter image description here The border appears to become transparent, and this only happens after hiding and showing the form.

I found out that the second form has no influence on this, it is only the act of hiding and showing the form. I had tried providing a fix by explicitly invalidating and updating pnlInfoBoard however, this appears to have no effect.

Here is the code:

private void btnInstructions_Click(object sender, EventArgs e)
{
    this.Hide();
    //Instructions frmInstructions = new TowerTitans.Instructions();
    //frmInstructions.ShowDialog(this);
    this.Show();
    pnlInfoBoard.Invalidate();
    pnlInfoBoard.Update();
}

Why would this happen?
How do I fix it?

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
Tyler
  • 957
  • 11
  • 27
  • Maybe related to [this](https://stackoverflow.com/questions/2695608/c-windows-forms-what-could-cause-invalidate-to-not-redraw)? – Manfred Radlwimmer Jan 27 '17 at 12:10
  • That's actually where I got the idea to invalidate and update pnlInfoBoard (object with the disappearing border). It is suppose to force an immediate redraw according to the accepted post; however, it doesn't seem to be doing anything in my code. Perhaps I am using the 2 methods incorrectly... – Tyler Jan 27 '17 at 12:12

0 Answers0