Using objects with secondary forms... Whats wrong here...
Hello...
I am trying to create a pop up save box for a program of mine...
Basically, I am calling a new form from the main form I have so:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Is the standard form I'm using that visual studio automatically creates. Now when you click a button(button1 in this case), I want to call a new form(form2), here is the code:
private void SaveVariable_Click(object sender, EventArgs e)
{
form2 saveform = new form2();
saveform.Show();
saveform.Visible = true;
}
}
// below is a new class
public class form2 : Form
{
//constructor
public form2()
{
//initialize components
Label label2 = new System.Windows.Forms.Label();
label2.AutoSize = true; // this.label2.AutoSize = true;
label2.Location = new System.Drawing.Point(55, 55);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(39, 13);
label2.TabIndex = 10;
label2.Text = "Label2";
label2.Visible = true;
}
}
However, when the program runs, while the new form object is created, no label box appears anywhere. What am I missing? I've tried using this.label2.X as well for all of the form2 variables but it doesn't change anything....