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 191421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:20:24+00:00 2026-05-11T16:20:24+00:00

I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,

  • 0

I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment, Plan, CaseNote etc. There are over 30 forms that make up the app with the UI broken down logically. Member, Enrollments, Plans, CaseNotes, etc.

I am trying to figure out how I can create my Person Object after searching on the Search Form and pass THE object to the next requested form. Whatever that may be, let’s say Demographics. The short of it is that I need the Person object to be available throughout the App and there can only be one.

Now I have ZERO exposure to Design Patterns but I am trying. I have read http://www.switchonthecode.com/tutorials/csharp-tutorial-singleton-pattern and http://www.yoda.arachsys.com/csharp/singleton.html but I want to make sure I understand correctly how to apply this to my situation.

First, the examples state that you are accessing a reference, correct? Am I mistaken or would I need to access the value?

Second, is there anything else that I need to do to make this Globally available? Do I just declare a instance on each form but through this Singleton Pattern so as to not have more then one?

Thanks

EDIT 1

To clarify, All objects are child objects of Person. Also, As the Search Page eludes to; the users can select a different currentPerson. But they can only interact with ONE Person at a time.

Lastly, as I stated I am an infant in this and if I should be considering something else, a different approach please say so and if you’d be so kind as to offer some explanation as to why, I’d be very grateful.

EDIT 2

Based on Medicine Man’s comment I thought I wauld clarify.

First, Thank you to everyone who has contributed so far.
Second, I don’t know the first thing about design patterns and I certainly don’t have the foggiest if a certain one is needed in my current situation.

If someone has a better, simpler, or ,in your opinion, a more fitting method of passing a Data Object from FORM to FORM to FORM then PLEASE tell.

In the end I just need a way of tracking the information as my users go from place to place.
Thank You


  • 1 1 Answer
  • 1 View
  • 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-11T16:20:24+00:00Added an answer on May 11, 2026 at 4:20 pm

    You can use the Singleton pattern to assure that only one instance is ever created.

    However, the jury is still out (at least in my mind) on whether this is a good decision. There’s plenty of reading on SO and other places about this.

    I would approach this from a different angle. I’d make all of my forms take in a Person instance in the constructor. That way, each form is only ever worried about it’s instance of Person.

    You could do this by creating a new class that inherits from Form and has a field/property/constructor for your Person. Then, any form that uses Person can inherit from your new class.

    You would, of course, have to manage the creation of your Person object. You could even do this with a singleton. However, the benefit is that each form doesn’t have to know how to create a Person or who created the Person. That way, if you choose to move away from the Singleton pattern, you wouldn’t have to go change all of your references to your singleton instance.

    EDIT:

    Here’s some code to demonstrate this. It took me a while to get the designer to play nice. I had to add an empty private constructor in PersonForm to get the designer to not throw an error.

    Program.cs

    static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MyDerivedForm(new Person { Name = "Hello World!" }));
            }
        }
    

    Person.cs

    public class Person
    {
        public virtual string Name { get; set; }
    }
    

    PersonForm.cs

    using System;
    using System.Windows.Forms;
    
    public class PersonForm : Form
    {
        private readonly Person myPerson;
    
        protected virtual Person MyPerson 
        {
            get
            {
                return this.myPerson;
            }
        }
    
        private PersonForm()
        {
        }
    
        public PersonForm(Person person)
        {
            this.myPerson = person;
        }
    }
    

    MyDerivedForm.cs (add a label named label1)

    public partial class MyDerivedForm : SingletonMadness.PersonForm
    {
        public MyDerivedForm(Person person)
            : base(person)
        {
            InitializeComponent();
        }
    
        private void MyDerivedForm_Load(object sender, EventArgs e)
        {
            label1.Text = this.MyPerson.Name;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I have a fairly large CRUD winform app that is set up to display
I work for a firm that provides certain types of financial consulting services in
I have a fairly large codebase that depends on MooTools v1.11 and am about
I have a fairly large PHP codebase (10k files) that I work with using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.