262Views8Replies
C# button on a form
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
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
Discussions
Best Answer 10 years ago
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.
Answer 10 years ago
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
Answer 10 years ago
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...
NAMEOFABOUTFORM frmAbout = new NAMEOFABOUTFORM();
Answer 10 years ago
thanks now how do i get it to close the form whin i hit the ok button
would it be like
application.exit
Answer 10 years ago
:) 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...
Answer 10 years ago
do you have any recomendations on book for visual studio
Answer 10 years ago
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.
Answer 10 years ago
thanks i didnt think of the library