How do you open a new Windows Form Application?
Like this: I have Form1 and Form2. When you click button1, Form2 opens up.
I tried:
andCode:Form2.ShowDialog;andCode:Form2.ShowBut none of them works.Code:Form2 f2 = new Form2(); Form2.ShowDialog;
I got this error for all of them
Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Users\McKinlays Laptop\AppData\Local\Temporary Projects\Test System\Form1.cs 22 13 Test System
Last edited by Roger; 01-09-2011 at 12:42 PM.
Double-Click on Button1 and type this code:
If you want to hide your current form type:Code:Form2.show
Code:Me.hide Form2.show
same error, except this time it also has this error also:Error 2 'Test_System.Form2' does not contain a definition for 'show' C:\Users\McKinlays Laptop\AppData\Local\Temporary Projects\Test System\Form1.cs 22 19 Test System
Could it be a "using" problem?
Code: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;
ShowDialog is a method, you must call it like this
Declare a new variable f2 as a Form2
Form2 f2 = new Form2;
f2.Show();
or
f2.ShowDialog();
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics
Thanks a ton! This fixed it!
Hurray!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks