I have a program with Form1 and Form2. How can I open form2 from form1 clicking a button?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just a little more info
having this in your Project.cpp: Application->CreateForm(__classid(TForm2), &Form2); means that the form will be created when you start your application.
if you want to create the form your self when clicking the button do the following
if for instance you need to use a custom constructor you can also create a new form passing in any values you need. for example
The above method besides setting the owner of the form passes in a string and a TDateTime you could then uses them in your forms constructor to do some stuff.
remember if you create these forms your self you will need to delete them.
to allow other buttons or controls also access you form you need to do the following
in the private section of the header add the following
now back in the cpp you will need to create teh form before you can use it, this changes slightly from the earlier one
but now if you want to access the form to say update the caption you can simply do
the caption on the form will now be changed