[C#] Ouverture d'une Form ( Form2.Show() ; )
Bonjour, je débutes actuellement en C# et un petit problème tout con viens de surgire lors de la compilation de mon programme (+ Visual C# 2005 Express) :
Le Code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace AppTEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2.Show();
}
}
} |
L'erreur (Form2.Show())
Citation:
Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' C:\Documents and Settings\Nadd\my documents\visual studio 2005\projects\AppTEST\AppTEST\Form1.cs 20 13 AppTEST
En vous remerciant d'avance,
Nadd
Re: [C#] Ouverture d'une Form ( Form2.Show() ; )
Ben oui, Elle est où ton instance de Form2 :roll:
Code:
1 2 3 4 5 6 7
|
private Form2 f2;
private void button1_Click(object sender, EventArgs e)
{
f2 = new Form2();
f2.Show();
} |