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
dbailiff
NA
13
0
Forms leaving scope?
Sep 27 2004 11:26 AM
I am programming an MDI application that allows a user to have multiple views of data. I accomplish this by using a datagrid in a MDI child form to the main form. The user can then have multiple child forms open each having its own data grid. Users began to report lost data when trying to update when multiple forms were open. Running through the debugger I discovered that the datagrid objects were being disposed even though a datagrid form was still open! I am wondering if my code is inherently flawed somehow and my child forms are out of scope? Here's a brief example: in frmMain()... private void mnuViewFinalPhrases_Click(object sender, System.EventArgs e) { string [] sfilter = {"status = 'F'"}; bool [] bcolumns = {true, true, true, true, true, true, false, false, false, false}; frmPhraseView frmFinalView = new frmPhraseView("Final Phrases", sfilter, bcolumns); frmFinalView.MdiParent = clsGlobal.g_frmMain; frmFinalView.Show(); } I've setup a global class to instantiate a static global form so that I could always refer back to the main from (clsGlogal.g_frmMain) from anywhere in the program. frmPhraseView contains my datagrid. I can create multiple forms this way by creating a new form every time the user clicks this menu item. I guess my question is this: Once the code execution leaves this member function, that is "mnuViewFinalPhrases_Click", will the form I create in this function go out of scope? Do I need to create some kind of static reference to this form to keep it from going out of scope?
Reply
Answers (
2
)
obtaining color depth of primary monitor
datagrid cell color changed based on dateTime