Opening/Closing(Hiding) Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am writing a Jeopardy-like game that contains three
forms. One is the Jeopardy board, another is the
Question/Answer displayer, and the last is the
scoreboard. I need to find a way to open the scoreboard
as hidden when the program starts. This is because the
scoreboard must constantly keep score, even when it is
not in use. I cannot seem to cause my program to access
the scoreboard from my question/answer displayer, which
is supposed to open it. I also do not know how to hide
or close the forms when I am not using them. I am
relatively new, so I do not have much expertise in these
simple areas.

-Thanks
 
You show or hide a form by calling it's Show() and Hide() and close it
with Close();

Another way to show scoreboard only when needed is to keep track of the
score in your question/answer class. When you need to show the score you
create a new scoreboard and pass the current score as a parameter. Then
use Show/ShowDialog on it.

public class Parent
{
int score;

private void ShowScore()
{
ScoreBoard sb = new ScoreBoard(score);
sb.ShowDialog(); // score.Show(); will open the scoreboard as modeless
instead
}
}

Or you could create it once and save the reference to sb, and then call
sb.Show()/sb.Hide() when you need it.
 
Hello

May I suggest that you do something a little different. Consider putting
all of the information on a single form. Ask the questions in one part of
the form, keep score in another. If you are as new as you appear to be, you
will be better off avoiding the complexity.

Now, to answer your original question:

if your score form is called "ScoreForm" then simply code:
ScoreForm.Hide;
in your main form code (assuming you created the ScoreForm from the main
form).


Good luck.
--- Nick
 
Back
Top