Hello, I'm new to this forum.
I'm kinda new to .NET, but I like it a lot. I'm working on a program that controls the rents payment in a building. So I decided it should have several modules: tenants, departments, rent, tax, and a "generate new payment" module, in case they have to pay for something else.
Anyway, I decided to use the MDI interface. I'm learning from a book I bought, so I don't know if there are other ways to do what I want to do. The problem is each module comes from one form, and there should be only ONE form of each module. The book has the following code, in C#:
This code is supposedly used on a menu, on "File", "New". So, you generate copies of the child form.
What I need is to only be able to generate one form and that's it. I don't know if there is a way to check if a class is already instantiated before you create an object of it (in this case, before you create a NewChildForm object, I would like to know if there is an already oppened or created ChildForm active).
I my mind, or my idea, is to use buttons that call each module: one button for rents, one button for departments, one button for tenants, etc. But each form is unique, so I don't want each button to generate copies of each form. Just open it or do nothing if it's already oppened (maybe just use the Show method again if it already exists).
Maybe the MDI is not the best way to do this, so I want to hear your oppinions.
Thanks in advice.
I'm kinda new to .NET, but I like it a lot. I'm working on a program that controls the rents payment in a building. So I decided it should have several modules: tenants, departments, rent, tax, and a "generate new payment" module, in case they have to pay for something else.
Anyway, I decided to use the MDI interface. I'm learning from a book I bought, so I don't know if there are other ways to do what I want to do. The problem is each module comes from one form, and there should be only ONE form of each module. The book has the following code, in C#:
Code:
//ChildForm is the name of an existing form, intented to be the model of all child forms
ChildForm NewChildForm;
NewChildForm = new ChildForm();
NewChildForm.Text = "Form" + MdiChildren.Length.ToString();
//The next line converts the form into a child form
NewChildForm.MdiParent = this;
NewChildForm.Show();
This code is supposedly used on a menu, on "File", "New". So, you generate copies of the child form.
What I need is to only be able to generate one form and that's it. I don't know if there is a way to check if a class is already instantiated before you create an object of it (in this case, before you create a NewChildForm object, I would like to know if there is an already oppened or created ChildForm active).
I my mind, or my idea, is to use buttons that call each module: one button for rents, one button for departments, one button for tenants, etc. But each form is unique, so I don't want each button to generate copies of each form. Just open it or do nothing if it's already oppened (maybe just use the Show method again if it already exists).
Maybe the MDI is not the best way to do this, so I want to hear your oppinions.
Thanks in advice.