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
nkt
NA
3
2.1k
Problem in creating MDI window forms
Apr 9 2011 2:51 AM
I have been try to create a window form in which when we open a new child form it checks if the child form is already open or not. If not open it create an new form but if a child form already exits it brings that form to front. I have tried using this code. It works fine for the first time but when i close the child form once & try to open it again it generates an exception saying, "Cannot use a disposed object.".
Pls someone help..
Thanks in advance...
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestProject
{
public partial class Form1 : Form
{
public static int flag1 = 0; // to check if form2 is already open or not...
public static int flag2 = 0; // to check if form3 is already open or not...
Form2 newform = new Form2();
Form3 newform1 = new Form3();
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
if (flag == 0)
{
flag = 1;
newform.MdiParent = this;
newform.Show();
}
else
{
newform.BringToFront();
}
}
private void new2ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (flag2 == 0)
{
flag2 = 1;
newform1.MdiParent = this;
newform1.Show();
}
else
{
newform1.BringToFront();
}
}
}
}
Reply
Answers (
1
)
Build a Custom RadioButton Grouping Cell and Column for the DataGridView Control
C# Windows application