Hi,
ich hab ein ähnliches Problem:
Hier der Code, das Ziel ist wenn ich auf ButtonEntertainment klicke daß das FormTS geschlossen wird und das FormEntertainment geöffnet wird.
program.cs
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormTS());
}
}
}
FormTS.cs:
namespace WindowsFormsApplication1
{
public partial class FormTS : Form
{
FormEntertainment entertainment = new FormEntertainment();
public FormTS()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void buttonEntertainment_Click(object sender, EventArgs e)
{
if (entertainment.IsDisposed)
entertainment = new FormEntertainment();
FormEntertainment.Show();
}
}
}
FormEntertainment.cs:
namespace WindowsFormsApplication1
{
public partial class FormEntertainment : Form
{
public FormEntertainment()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Der Debugger schmeisst an Fehler sobald ich auf den ButtonEntertainment drücke.
"Auf das verworfene Objekt kann nicht zugegriffen werden.
Objektname: FormEntertainment."
Gruss