Hey, I was just wondering how I can get it so when I click a button it opens my second form. But sets some of the labels to a specific thing, so I don't end up making 170+ forms for my periodic table application. Just like so when I click "H" it opens the "Form2" and sets the label "atomname" to "Hydrogen"?

Here's my buttonclick so far.

private: System::Void hydrogen_Click(System::Object^  sender, System::EventArgs^  e) {
				 Form2^ newform2 = gcnew Form2;
				 newform2->ShowDialog();

Define your own constructor for Form2 that accepts this information and sets control values accordingly. For example:

Form2^ frm = gcnew Form2("Hydrogen");

frm->ShowDialog();

Define your own constructor for Form2 that accepts this information and sets control values accordingly. For example:

Form2^ frm = gcnew Form2("Hydrogen");

frm->ShowDialog();

This didn't work. Upon entering this exactly I got:

1>c:\users\blackmethod\documents\visual studio 2010\projects\valestrom's periodic table\valestrom's periodic table\Form1.h(2086): error C3673: 'ValestromsPeriodicTable::Form2' : class does not have a copy-constructor


Help on what's wrong here?

Help on what's wrong here?

You didn't provide any code, so I can only guess that you failed to actually write the constructor.

You didn't provide any code, so I can only guess that you failed to actually write the constructor.

I copied your exact code.

My exact code was incomplete. So if you didn't also add a corresponding constructor, my guess was correct.

My exact code was incomplete. So if you didn't also add a corresponding constructor, my guess was correct.

I was in a hurry, I got your reply and tried it right off, sorry. What part of it is incomplete.

What part of it is incomplete.

How many times do I have to repeat myself? You must write the constructor that is being called.

How many times do I have to repeat myself? You must write the constructor that is being called.

Still have no idea about how to do it, but you gave me enough info that google should be my friend.

commented: Kudos for not expecting everything to be done for you. :) +17
<include FormName.h>

Form1::Visible = false;
FormName ^ Form2 = gcnew FormName();
Form2->ShowDialog();

That should be more than enough.. It's what I use.. If u made your form2 in the same project as Form1.h then just include the Form2.h file in the first form.. that way u don't need to make a constructor & destructor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.