How to show a ABOUT Form????????

D

Delphiscn

How to show a ABOUT Form????????

Hello Everyone:
I use C# want to Create a Project. In my project. there are two
forms. One is main form, and another is a about form. In the about
form there are some information about my project. such as author's
information, product support and so on.
Now, I add a button in the main form, I want that if the user click
the button. It will show the about form . In button's event . the code
like this:
{
about.show();
}
but it doesn't work, if in Delphi. It will be work.
After that, I search the msdn. I know that there is a method called
AddOwnedForm(); so I coded the code like below:
{
Form cs =new Form();
this.AddOwnedForm (cs);
cs.Show();
}
This can show a new Form , but it is not the about form....
What I should do? I'm very sorry for my English , I 'm from China.
 
J

Jeff Hopper

You should just be able to do this in the main form's button click event
handler:

private void buttonAbout_Click(object sender, EventArgs e)
{
new about().ShowDialog();
}

Jeff Hopper
 
P

Peter Duniho

You should just be able to do this in the main form's button click event
handler:

private void buttonAbout_Click(object sender, EventArgs e)
{
new about().ShowDialog();
}

Close. Except that this code fails to dispose the dialog when you're
done. Forms that are shown modally are not disposed automatically when
you close them, so your own code must do it explicitly.

So better would be:

using (Form about = new about())
{
about.ShowDialog();
}

Pete
 
J

Jeff Hopper

Very good point, Pete!

Jeff

You should just be able to do this in the main form's button click event
handler:

private void buttonAbout_Click(object sender, EventArgs e)
{
new about().ShowDialog();
}

Close. Except that this code fails to dispose the dialog when you're
done. Forms that are shown modally are not disposed automatically when
you close them, so your own code must do it explicitly.

So better would be:

using (Form about = new about())
{
about.ShowDialog();
}

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top