Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am making a program in which a user clicks "yes" or "no". Then a message box pops up and then after the user clicks ok, i want it to show a new form that i have created. the thing is i don't know how to program the program to switch to another form. And yes, I have tried form2.Show and it doesn't work. I also tried form2.Show(). Please help!

Here is the code(and yes i know its a stupid program, but I'm new and i'm playing around with it:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Good choice");
Form2.Show;
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Eh");
}
}
}
Posted
Updated 26-Jun-11 8:05am
v2
Comments
Sergey Alexandrovich Kryukov 25-Jun-11 2:47am    
You've written "form2.Show" twice. It works; you did something wrong. I don't see what.
--SA

try this:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Good choice");

Form2 frm = new Form2();
frm.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Eh");
}
}
}


hope this helps :)
 
Share this answer
 
Comments
Member 8034274 30-Jun-11 0:20am    
oh ok thanks, ill try this out :)
It should be as simple as this.[^], so unless you post some code here it will be hard for anyone to detect what could be going wrong.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900