You are viewing our Forum Archives. To view or take place in current topics click here.
Quick C# Question +50rep
Posted:

Quick C# Question +50repPosted:

xChillest
  • TTG Addict
Status: Offline
Joined: Jul 30, 201211Year Member
Posts: 2,396
Reputation Power: 123
Status: Offline
Joined: Jul 30, 201211Year Member
Posts: 2,396
Reputation Power: 123
I have a project that uses a main form to open other forms for different games. When a new form opens, the original form is closed. I'm trying to set it up to open a messagebox when you close the new form, asking to restart the program or close it completely. I've got the coding looking correct, but every time I try to debug the program won't open at all.

at the top I have

using Wildfire0;


a little further down, right after defining XRPC

Wildfire wildfire = new Wildfire();


Then this

private void Skyrim_FormClosing(object sender, FormClosingEventArgs e)
            {
                DialogResult dlgresult = MessageBox.Show("Would you like to restart the program? Click Yes to restart Wildfire, click No to close it completely.", "Wildfire", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dlgresult == DialogResult.Yes)
                {
                    wildfire.ShowDialog();

                }
                else
                {
                    Application.Exit();
                }
            }


All of it seems fine and not giving any errors, but when I try to debug the program just will not open :/ Whoever can help me get this working will be sent +50 rep
#2. Posted:
ProjectJasper
  • Ladder Climber
Status: Offline
Joined: Aug 24, 201310Year Member
Posts: 355
Reputation Power: 14
Status: Offline
Joined: Aug 24, 201310Year Member
Posts: 355
Reputation Power: 14
everything looks okay to me except for

private void Skyrim_FormClosing(object sender, FormClosingEventArgs e)



try messing with this line of code a bit
#3. Posted:
Bithax
  • New Member
Status: Offline
Joined: Jun 08, 20149Year Member
Posts: 9
Reputation Power: 2
Status: Offline
Joined: Jun 08, 20149Year Member
Posts: 9
Reputation Power: 2
Perhaps on the loading process of the 2nd forum, you should close the first one?

Just add this before the constructor

Load += new EventHandler(Form2_Load);

void Form2_Load(object a, EventArgs e)
{
     using (Form1 form = new Form1())
     {
         form.Close();
     }
}
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.