TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Henry Vuong
NA
27
0
Cannot re-open a form after it was closed
Sep 16 2008 2:19 PM
I have a parent form (Main) and a child form (form1). The parent form's IsMdiContainer is set to true. When I click on a menu item, the child form is opened within the parent form, no problem. But when I close the child form and try to re-open it by clicking on the menu item again, it does not show, and there's an error: "Invisible or disabled control cannot be activated."
It appears that form1 is not really closed, it's just hidden somewhere but somehow I cannot re-display it. I tried both form1.Show() and form1.Visible = true but nothing works. Here's my code:
public partial class Main : Form
{
Form1 form1;
public Main()
{
InitializeComponent();
}
private void form1ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (form1 != null)
{
form1.Show();
this.ActiveControl = form1;
form1.WindowState = FormWindowState.Normal;
form1.BringToFront();
return;
}
else if (form1 == null || form1.IsDisposed)
{
form1 = new Form1();
form1.MdiParent = this;
form1.TopLevel = false;
form1.Dock = DockStyle.Fill;
form1.Show();
this.ActiveControl = form1;
form1.BringToFront();
}
}
}
Reply
Answers (
2
)
try catch performance hit?
csharp delete Query