I'm trying to close a form in C#. I have a vb background, so the question
may sound dumb. In vb it is just me.close(). I've tried a bunch of ways to
close the form but C# is acting pretty dumb also. I can't find a way to
close it. Here are some of the things I've tried:
private void button1_Click(object sender, System.EventArgs e)
{
// Form1 frmI = new Form1();
// DialogResult dr = frmI.ShowDialog();
Form1.Quit();
// this.Hide();
}
The new form seems to recreate the form - that is a total nightmare. Hide
doesn't end the program and Close just gets a message that says close is not
defined.

Signature
Regards,
Jamie
thejamie - 21 Apr 2005 20:04 GMT
Thanks... tried again with This.close(); and this time it worked. Not sure
what was going on but thanks for the help.
> I'm trying to close a form in C#. I have a vb background, so the question
> may sound dumb. In vb it is just me.close(). I've tried a bunch of ways to
[quoted text clipped - 14 lines]
> doesn't end the program and Close just gets a message that says close is not
> defined.
Herfried K. Wagner [MVP] - 21 Apr 2005 20:10 GMT
"thejamie" <thejamie@discussions.microsoft.com> schrieb:
> Thanks... tried again with This.close(); and this time it worked. Not
> sure
> what was going on
Note that C# is case-sensitive!

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
thejamie - 21 Apr 2005 20:15 GMT
Whoa... it isn't self correcting! I'm glad you mentioned this.
Thanks again.
> "thejamie" <thejamie@discussions.microsoft.com> schrieb:
> > Thanks... tried again with This.close(); and this time it worked. Not
> > sure
> > what was going on
>
> Note that C# is case-sensitive!
Herfried K. Wagner [MVP] - 21 Apr 2005 20:09 GMT
"thejamie" <thejamie@discussions.microsoft.com> schrieb:
> I'm trying to close a form in C#. I have a vb background, so the question
> may sound dumb. In vb it is just me.close(). I've tried a bunch of ways
[quoted text clipped - 16 lines]
> not
> defined.
Mhm... 'this.Close();' should work.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
rmacias - 21 Apr 2005 20:11 GMT
I'm assuming button1_Click() is an event handler for a button on the form
that you want to close. So if you want to close the form, it would look like
this:
private void button1_Click(object sender, System.EventArgs e)
{
this.close();
}
If this form is the entry point for your application, then the applicaton
will exit when the form is closed. If this form is not the entry point to
your application, but want to close the application, you could use
Application.Exit(); to end your program.
> I'm trying to close a form in C#. I have a vb background, so the question
> may sound dumb. In vb it is just me.close(). I've tried a bunch of ways to
[quoted text clipped - 14 lines]
> doesn't end the program and Close just gets a message that says close is not
> defined.