[RESOLVED] Parent/Child Form Problem [open and closing them]
Hi all,
My project is a game, a Hangman game, i have problems with forms, as follows:
First I want my project to have a splash screen and i put it as start-up form, then when splash screen finish executing itself, it hides itself and load the menu form then if you chose new game in menu form it loads new form "pre-game" i did this form to get from the user some parameters for the game,
from the pre-game form is a button to start the game and shows the "game" form, but as you can see the parent child relationship is like this:
Splash screen -> Main Menu -> pre-game -> Game.
Now my problem is .. I can't close the Menu form when the Game form loads, or even hide it. Is there any way to load a form independent from other
(i mean not as parent/child relationship), just load a form as a parent itself...
I'm waiting for a reply.
Thanks in advance
Jareck
Re: Parent/Child Form Problem [open and closing them]
Here's how I suggest displaying a spalsh screen in C#
http://www.vbforums.com/showthread.php?t=628109
The other forms can be displayed from the Main method before the main form, either by calling Application.Run or ShowDialog.
Re: Parent/Child Form Problem [open and closing them]
ok, im going to take a look for the splash screen... thnx
but can you give me a simple example how to use application.run
because i was using ShowDialog but still couldn't close the parent form from the child one...
Re: Parent/Child Form Problem [open and closing them]
Quote:
Originally Posted by
jareck
because i was using ShowDialog but still couldn't close the parent form from the child one...
There is no parent or child form and no form is closing any other. The forms are all opened from the main method and they each close themselves.
Re: Parent/Child Form Problem [open and closing them]
I'm really confused right know ! to make my question more clearly... Let's guess I have form1 and form2, is there any way to show form2 from form1 e.g with a button click and then with another button in form2 to close the form1 ?
Re: Parent/Child Form Problem [open and closing them]
Yes, but I don't quite understand why you would want to in this case. What's the first form that's being closed and what's the second form that's closing it?
Re: Parent/Child Form Problem [open and closing them]
I want'ed to do that because when the game form was shown I wanted the Menu form to be closed, it just was annoying in that way.
However thnx a lot for your help, I found the solution here:
Code:
public static void ThreadProc()
{
Application.Run(new Form());
}
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
t.Start();
}
Reference: http://social.msdn.microsoft.com/for...-426521fe60f1/