field33

I want to show an form, but I don't know the code.

I know that it's in VB like the following:

Code Snippet

Form.Show()

but now i'm working with C#. Can anybody help me


Re: Visual C# Express Edition [noob question] Showing an form

Philly

its exaclty the same,

heres a small example

Code Snippet

using System;

using System.Windows.Forms;

namespace ShowForm

{

static class Program

{

static Form myForm = new Form();

[STAThread]

static void Main()

{

// Heres the form show

myForm.Show();

while (myForm.Created)

{

Application.DoEvents();

}

}

}

}

hope this helps,

Philly





Re: Visual C# Express Edition [noob question] Showing an form

ahmedilyas

It's bad practice to use Application.DoEvents() - never use it as you can have undesirable effects. The correct method is more or less the same as above....

MyForm theForm = new MyForm();

theForm.Show(); //or ShowDialog() depending on the behaviour of the dialog you want






Re: Visual C# Express Edition [noob question] Showing an form

field33

Won't work

EDIT: More things are wrong, if I use this, then Show is in the list, but if I use AboutBox1, then it will error.






Re: Visual C# Express Edition [noob question] Showing an form

ahmedilyas

what wont work any errors what happens




Re: Visual C# Express Edition [noob question] Showing an form

field33

AboutBox1.Show(); won't work. If I use this, this will occur if I debug it:

Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()'

Do you know more about this




Re: Visual C# Express Edition [noob question] Showing an form

ahmedilyas

can you show the entire code you are using

I'm guessing your not making an instance of the object. you should be doing:

AboutBox1 myAbout = new AboutBox1();

myAbout.Show();






Re: Visual C# Express Edition [noob question] Showing an form

field33

ahmedilyas wrote:

can you show the entire code you are using

I'm guessing your not making an instance of the object. you should be doing:

AboutBox1 myAbout = new AboutBox1();

myAbout.Show();

You fixed my problem. Thank you.