I have a button on Form1 that opens Form2(Leaderboard) if Form2 is not open. What I am trying to do is: On Button click, if Form2 is closed, open Form2. Else Form2 is open, bring Form2 to front.
With the below code, clicking the button when leaderboardOpen == true;
does nothing at all.
public static bool leaderboardOpen = false;
private void leaderButton_Click(object sender, EventArgs e)
{
if (leaderboardOpen == false)
{
Leaderboard leaderboard = new Leaderboard();
leaderboard.Show();
leaderboardOpen = true;
}
else
{
Leaderboard leaderboard = new Leaderboard();
//Tried the below
//leaderboard.Focus();
//leaderboard.BringToFront();
//leaderboard.TopMost = true;
//leaderboard.Activate();
}
}