I am using a Windows Form application. First, a specific form appears, and after the user clicks the next button, this form should be hidden and another form shown.
I tried to do it. I managed to hide the current form, but the next one will not be displayed.
Here is my attempt:
This is a button event handler
private void button1_Click_1(object sender, EventArgs e)
{
if (richTextBox1.Text != null)
{
this.Visible=false;
}
else
MessageBox.Show("Insert Attributes First !");
}
This is the main function:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form2 form2 = new Form2();
Form1 form1 = new Form1();
form2.Hide();
Application.Run(form1);
while (true)
{
if (form1.Visible == false)
form2.Show();
}
}
source
share