Closed Thread
Results 1 to 5 of 5

Thread: Quick Question - open a new Windows Form Application

  1. #1
    JakeWindu is offline Newbie
    Join Date
    Nov 2009
    Posts
    21
    Rep Power
    0

    Quick Question - open a new Windows Form Application

    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:
    Code:
    Form2.ShowDialog;
    and
    Code:
    Form2.Show
    and
    Code:
                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
    Last edited by Roger; 01-09-2011 at 12:42 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    iluxon4ik's Avatar
    iluxon4ik is offline Newbie
    Join Date
    Jan 2010
    Posts
    18
    Rep Power
    0

    Re: Quick Question

    Double-Click on Button1 and type this code:
    Code:
    Form2.show
    If you want to hide your current form type:
    Code:
    Me.hide
    Form2.show

  4. #3
    JakeWindu is offline Newbie
    Join Date
    Nov 2009
    Posts
    21
    Rep Power
    0

    Re: Quick Question

    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;

  5. #4
    Davide's Avatar
    Davide is offline Programming God
    Join Date
    Dec 2009
    Location
    Manchester, UK
    Posts
    507
    Blog Entries
    8
    Rep Power
    11

    Re: Quick Question

    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

  6. #5
    JakeWindu is offline Newbie
    Join Date
    Nov 2009
    Posts
    21
    Rep Power
    0

    Re: Quick Question

    Thanks a ton! This fixed it!

    Hurray!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Windows Form Application help
    By Cybertech44 in forum Managed C++
    Replies: 9
    Last Post: 07-19-2011, 10:47 AM
  2. Replies: 9
    Last Post: 09-14-2010, 01:54 PM
  3. Replies: 1
    Last Post: 11-19-2007, 09:42 AM
  4. windows.form.treeview control question
    By hoser2001 in forum C# Programming
    Replies: 11
    Last Post: 07-13-2006, 10:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts