Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 908011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:38:47+00:00 2026-05-15T16:38:47+00:00

I have a MDI application. One of the forms needs to be able to

  • 0

I have a MDI application. One of the forms needs to be able to have multiple instances of it open at the same time. Within this app I have a Program class. For each instance of the form I need to place a Program object into each form. This is working, however, everytime data is changed it changes all of the Program objects within all of the multiple instances of the form.

Here is the Program class (very simple class for now):

public class Program
{
string strProgramCode;

public Program()
{ }

public string ProgramCode
{
    get { return strProgramCode; }
    set { strProgramCode = value; }
}

}

Here is the code for the form:

            frmWeeklyIndividualBudgets tfrmWeeklyIndividualBudgets = new frmWeeklyIndividualBudgets();
            tfrmWeeklyIndividualBudgets.Program = this.Program;
            tfrmWeeklyIndividualBudgets.Text = this.Program.ProgramCode.ToString() + " Weekly Budget";
            this.CheckMdiChildren(tfrmWeeklyIndividualBudgets);

Here is the CheckMdiChildren method:

private void CheckMdiChildren(Form form)
{ 

    foreach (Form frm in this.MdiChildren)
    {
        if (frm.GetType() == form.GetType())
        {
            if (frm.GetType().ToString() == "IPAMFinancial_Program_Financial_Breakdown.frmWeeklyIndividualBudgets")
            {
                frmWeeklyIndividualBudgets tfrm = (frmWeeklyIndividualBudgets)frm;
                if (tfrm.Program.ProgramCode == this.Program.ProgramCode)
                {
                    frm.Focus();
                    return;
                }
            }
            else
            {
                frm.Focus();
                return;
            }
        }
    }

    form.MdiParent = this;
    form.Show();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:38:48+00:00Added an answer on May 15, 2026 at 4:38 pm

    I strongly suspect the problem is that you’ve got one Program object, which all the forms refer to. (That’s certainly what the code looks like.) Give each form a new Program instead, when you create the form.

    For example:

    frmWeeklyIndividualBudgets tfrmWeeklyIndividualBudgets = 
        new frmWeeklyIndividualBudgets();
    
    // Give the new form a new Program instance
    tfrmWeeklyIndividualBudgets.Program = new Program();
    tfrmWeeklyIndividualBudgets.Text = this.Program.ProgramCode.ToString() 
        + " Weekly Budget";
    this.CheckMdiChildren(tfrmWeeklyIndividualBudgets);
    

    If you want the new form to get a Program based on the existing one, you should implement a Clone method in Program, and do:

    tfrmWeeklyIndividualBudgets.Program = this.Program.Clone();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a tabforms in my application and whenever i open the multiple forms
I have a(n) (MDI) Windows Form application. It contains two forms. One form (Measured
I have a windows application with an MDI form and some child forms. I
I have a MDI Application with one MDI child. When a user changes a
I have an MDI Windows Forms application (.net 2008) that allows the user to
I have a MDI Windows Forms application. The main form, among the other events,
Does IntelliJ have any special support for developing a MDI (Multiple Document Interface) application?
I have a MDI application. This MDI application has lots of other tools including
My application looks like this: I have an MDI parent form - form1, the
I have written an MDI based application, in which the child forms are of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.