c# - MonoState, Singleton, or Derived Forms: Best approach for CRUD app? -


I have a large CRUD WinForm app in which there are many objects person, nomination, planning, case notes etc.

There are more than 30 forms that logically break above the app with the URL. Members, Nominations, Plans, Case Notes, etc.

I am trying to figure out how after searching on search form I can make my person object and pass on whatever the object on the next request form, we say that demographics is low I need the person's item to be available during the app and there is only one.

Now I have zero risk for design pattern but I am trying. I have read, but I want to make sure that I understand it correctly in my situation.

At first, the examples show that you are reaching context , right? Am I wrong or will I need to reach value ?

Second, is there anything that is to make me available globally? Do I just declare an example on each form through a singleton pattern so that there is no more after one?

Thanks

Edit1

To clarify, all the objects are the person's child objects, and not the same as the search page. ; Users can choose a different current person but they can only contact ONE at a time

Finally, as I said If I am a child in this and if I should think more, then please say a different perspective and if you are so kind that why I give some explanation, I would be very grateful.

Edit 2

Based on the comments of the Medicine Man, I thought I am clear.

First of all, till now. Second, I do not know about the design pattern first and I certainly do not have the worst condition if it is definitely necessary in my current situation.

If any better, simpler, or, in your opinion, a more suitable method for passing a data object from Form M to please, please tell me

Finally just me One way to track information is because my users take place from place you can make a singleton assurance assurance that only one instance is created

However, (At least in my mind) whether it is a good decision or not. There is a lot to read about this at SO and other places.

I will contact it at a different angle. I take all my forms in a person example in the constructor. In this way, each form is concerned only about that it is an example of a person.

You can do this by creating a new class that comes from the form and is a field / property / constructor for your person. Then, the person using any form can get it from your new class.

You must, of course, manage the creation of your person's object. You could also do this with a singleton. However, the benefit is that every form does not have to know who has created a person or who has created a person. In this way, if you choose, you do not have to change all your references in your own context.

Edit:

I have some time to make the code designer look good for something here. I had to add an empty personal constructor to the person to not throw the designer in error.

Program.cs

  Fixed class programs {/// & lt; Summary & gt; Main entry point for the application /// & lt; / Summary & gt; [STAThread] Fixed Zero Main () {Application.EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (wrong); Application Turn on (New MyDerivedForm (new person {name = "Hello World!"})); }}  

Person.cs

  public class person {public virtual string name {get; Set; }}  

PersonForm.cs

 using the  system; Using System.Windows.Forms; Public Sector PersonForm: Form {Private Redoni person myPerson; Protected virtual person MyPerson {Receive. This.myPerson; }} Private person () {} public person (person) {this.myPerson = person; MyDerivedForm.cs (label name add label 1)  
  Public partial class MyDerivedForm: SingletonMedance.prasansform {public MyDerivedForm (person person): support (Person) {InitializeComponent (); } Private Zero MyDerivedForm_Load (Object Sender, EventArgs e) {label1.Text = this.MyPerson.Name; }}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -