Reputation: 1
I am doing a project in C# window forms. I had created login form and admin form. After login admin form will show, in that form one button is their i.e, logout. On clicking it showing an error message "form that is already displayed modally cannot displayed as modal dialog box close the form before calling showDialog". on clickin login button (login)
this.Hide();
admin a = new admin();
a.ShowDialog();
onclicking logout button
private void button4_Click(object sender, EventArgs e)
{
this.Close();
login l = new login();
this.ShowDialog(l);
}
Upvotes: 0
Views: 85
Reputation: 3811
under the login button:
private void loginButton_Click(object sender, EventArgs e)
{
Hide();
var admin = new Admin {Owner = this};
admin.Show();
}
Under the LogOut button:
private void logoutButton_Click(object sender, EventArgs e)
{
Owner.Show();
Close();
}
Upvotes: 0
Reputation: 26209
Replace This:
a.ShowDialog();
With This:
a.Show();
Replace This:
this.ShowDialog(l);
With This:
this.Show(l);
Upvotes: 1