none
form.show(); in c#

    Question

  • Hi I'm new to c# -- trying to switch to a different form in a mobile app. 

     

    I start with:

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    namespace SwitchFormTest

    {

    public partial class Form1 : Form

    {

    public Form1()

    {

    InitializeComponent();

    }

    private void menuItem2_Click(object sender, EventArgs e)

    {

    Form2.show();

    }

    }

    }

     but when I try to run debugger it says "SwitchFormTest.Form2 does not contain a definition for show"

    VS offer is generate a method stub on Form2 and throws in the following to the form2 code:

    internal static void show()

    {

    throw new Exception("The method or operation is not implemented.");

     

    Then when I run the debugger the app of course throws an exception there. 

     

    Any advice?

     

    THanks

    Tuesday, November 13, 2007 7:12 AM

Answers

All replies

  • Hi,

    did you try:

    Form2 form2 = new Form2();

    form2.show();


    Cheers, Peter


    Tuesday, November 13, 2007 8:02 AM
  • Thanks so much!!

    Tuesday, November 13, 2007 3:51 PM
  • i need help..

    i am using form.show(); to jump to another form named menu.. i ve used the code u suggested.. but its not working..

     

     

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    namespace DeviceApplication2

    {

    public partial class form1 : Form

    {

    public form1()

    {

    InitializeComponent();

    }

    private void login_Click(object sender, EventArgs e)

    {

    menu m = new menu();

    m.show();

    }

    }

    }

    • Proposed as answer by venuchary Thursday, December 23, 2010 5:48 AM
    Friday, April 11, 2008 2:38 PM
  • your show() method does not exits for sure. because it is case sensitive. so it should be m.Show(). hope this helps
    Monday, September 07, 2009 9:55 AM
  • hello

    i was used previous code but i get error like this "Error   1   The type or namespace name 'Form2'

    could not be found (are you missing a using directive or an assembly reference? "

     

    i was created two window form then i still not get it.

    Thursday, December 23, 2010 5:38 AM
  • You need to create an object of that particular form, you want to open.

    Like Form name is then you will code it like

    CustomerDetails myform=new CustomerDetails();
    myform.Show();

    CustomerDetails() is the constructer of CustomerDetails. I hope you have enough knowledge of Constructors.

     

    :)Vote and mark so that you get marked and voted

    • Proposed as answer by Faisal Hayat Thursday, January 20, 2011 1:27 PM
    Thursday, January 20, 2011 1:27 PM
  • Thanks Faisal it worked.
    Saturday, November 03, 2012 12:21 PM