Jump to content

Quick Question - open a new Windows Form Application

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
JakeWindu

JakeWindu

    Newbie

  • Members
  • PipPip
  • 21 posts
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:
Form2.ShowDialog;
and
Form2.Show
and
            Form2 f2 = new Form2();

            Form2.ShowDialog;

But none of them works.
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

Edited by Roger, 09 January 2011 - 12:42 PM.


#2
iluxon4ik

iluxon4ik

    Newbie

  • Members
  • PipPip
  • 18 posts
Double-Click on Button1 and type this code:
Form2.show

If you want to hide your current form type:
Me.hide
Form2.show


#3
JakeWindu

JakeWindu

    Newbie

  • Members
  • PipPip
  • 21 posts
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?

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;


#4
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
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

#5
JakeWindu

JakeWindu

    Newbie

  • Members
  • PipPip
  • 21 posts
Thanks a ton! This fixed it!

Hurray!