Author Options:

C# button on a form Answered

i'm trying to make a form i have the form and the about box made i just need to assign the about box to the about button on the form does anybody know how to do that



Hey hightekrednek2396...

The issue many people struggle with, regarding C#, is that the forms are actually classes... you can only use instance members... you need to first create a new instance of that class (object) to play with it... so say your about form is Form2...

Form2 frmAbout = new Form2(); // create the instance of your form
frmAbout.Show(); // do something with it

There are many communities on the web to help with the basics of C# etc... use google to find a good one... and enjoy their experience and resources.

ok now when i typed that in it made the second form show up not the about box
how do i get it to show the about box

Yes... you will have to make an instance of the about form... I guessed that it may have been called Form2 by default... use whatever it was called by default... or whatever you named it...


thanks now how do i get it to close the form whin i hit the ok button

would it be like


:) I think it's time you used the power of google (faster answers and as you are new to C# the communities that you find will be very helpful)... All the best...

Like any language, you learn it best by using it... personally I would recommend playing with some tutorials first (there are lots on the web)... read some example code to see how it works... forums like that of the codeproject or CodeGuru are great. Programming books are written in different ways... some will fit well with your learning style... check them out at your local library.