New to C#

  • Thread starter Eric D. Anderson
  • Start date
E

Eric D. Anderson

Well I am somewhat new to programming in c#. And I am having a hard time figuring out how to open up a 2nd form within my program.

Here is what I am wanting to do:

When I click the "about" option from the menuStrip within my program, I want it to open up a form that I created, and show the user the information about my program.

I have already created the About form that I want to use, but I don't know how to make it show up when the about option is clicked. Any suggestions?
 
P

Peter Duniho

Eric D. Anderson said:
[...]
I have already created the About form that I want to use, but
I don't know how to make it show up when the about option is
clicked. Any suggestions?

Generally speaking, to show a form you must first create an instance of it,
and then call the Show method. For example:

AboutForm afrm = new AboutForm();

afrm.Show;

You may want your About form to be modal. That is, to not allow any
interaction with other windows in the process while it's showing. In that
case, you can call the ShowDialog method instead of Show.

Hope that helps. By the way, please don't post to newsgroups using HTML.
Plain text is appropriate here.

Pete
 
C

cbmeeks

That should be afrm.Show(); but Eric was on the right track. :)

Also, if you are spawning the new form within a MDI container, add this
BEFORE you call the Show() method:

afrm.MdiParent = this;

By using "this", I am assuming you have setup your main form as a MDI
container.

Good luck!
cbmeeks
----------------------------------------------------------------
Are you a Programmer??
http://www.codershangout.com

C#, .NET, SQL, and more!



Peter said:
Eric D. Anderson said:
[...]
I have already created the About form that I want to use, but
I don't know how to make it show up when the about option is
clicked. Any suggestions?

Generally speaking, to show a form you must first create an instance of it,
and then call the Show method. For example:

AboutForm afrm = new AboutForm();

afrm.Show;

You may want your About form to be modal. That is, to not allow any
interaction with other windows in the process while it's showing. In that
case, you can call the ShowDialog method instead of Show.

Hope that helps. By the way, please don't post to newsgroups using HTML.
Plain text is appropriate here.

Pete
 
E

Eric D. Anderson

Thanks a lot you guys for your help. I finally figured it out. Just like
Peter had said I needed to call the show method.

--
Eric D. Anderson
Well I am somewhat new to programming in c#. And I am having a hard time
figuring out how to open up a 2nd form within my program.

Here is what I am wanting to do:

When I click the "about" option from the menuStrip within my program, I want
it to open up a form that I created, and show the user the information about
my program.

I have already created the About form that I want to use, but I don't know
how to make it show up when the about option is clicked. Any suggestions?
 

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