Hi everyone, i have a problem:
Here is my case:
i already command a NewForm to be called everytime the user select that. The MainForm is being called when i run the program, and when i click "NewForm", the FirstNewForm being called and the MainForm is closed. But, when i click "NewForm"
again in the FirstNewForm that i had created, it called the SecondNewForm, but the FirstNewForm is not being closed.
Here is my question:
How do i close the FirstNewForm? i mean, how do i close a CurrentForm whenever i called a NewForm?
Here is the image when i command a "NewForm" when the MainForm still in there (not being showed in here, because i can upload only 2 images), and MainForm is closed when FirstNewForm being called:
(if you see in the taskbar, just one Selling System Program in there)
Here is the image when i command a "NewForm" when the FirstNewForm still in there, and FirstNewForm is not being closed when SecondNewForm being called: (if you see in the taskbar,there are two Selling System Programs in there, so the FirstNewForm
is not being closed)
How do i hide and close the FirstNewForm?
Here is the code:
private void AddNewForm(object sender, EventArgs e) { this.Hide(); Form newForm = new Form(); AddObjects(sender, e, newForm); UpdateTextPosition(sender, e, newForm); newForm.Size = new Size(1360, 735); newForm.Text = "Selling System"; newForm.FormBorderStyle = FormBorderStyle.Fixed3D; newForm.AutoScaleMode = AutoScaleMode.Font; newForm.AutoScroll = true; newForm.AutoSizeMode = AutoSizeMode.GrowAndShrink; newForm.StartPosition = FormStartPosition.CenterScreen; newForm.MaximizeBox = false; newForm.Controls.Add(label1); newForm.Controls.Add(label2); newForm.Controls.Add(label3); newForm.Controls.Add(label4); newForm.Controls.Add(label5); newForm.Controls.Add(label6); newForm.Controls.Add(label7); newForm.Controls.Add(menuStrip1); newForm.ShowDialog(); this.Close(); }
Thanks in advance! and sorry if i am post a long posting