Club Manager : FormManager

So we are all done. How do we run it? In order to run we need to Add Plan Manager in our Menu Bar, create an object of frmMemberShipPlan and call show on the same. But clicking the menu item again and again will result in multiple instances of frmMemberShipPlan, so we write our FormManger to handle all this.

FormManager will have static instances of all the forms.

namespace ClubManager
    public class FormManager
        public static frmMemberShipPlan MemberShipPlan = new frmMemberShipPlan();
        public static frmMain Main = new frmMain();
        static FormManager()
            MemberShipPlan.MdiParent = Main;

We also update our Program.cs to get Main form from our FormManager

static void Main()

How about adding menu now? Go to frmMain Designer View and Add Plan Manager under Membership Plan Menu item (We removed all menu items added earlier). In click event show and focus frmMemberShipPlan

private void planManagerToolStripMenuItem_Click(object sender, EventArgs e)

But what if user closes the child form, our click event will fail. We need to prevent that so in FormClosing event simple cancel the event and Hide the form.

private void frmMemberShipPlan_FormClosing(object sender, FormClosingEventArgs e)
    e.Cancel = true;

Before we run our application for the first time, please add the reference to project Core.Data.Mongo. You may ask why do we need to add this reference when my project is compiling perfectly and my application is not tightly bounded to any Database. Answer is Application requires this dll at runtime to perform its Data operations and you will have to copy this dll manually in that case. But if you add the reference then you need to not to do this manually.

Also some Decoration on our Main Form.

  • Set Text of form to “My Club“, we will also make it configurable later on.
  • Set WindowState to “Maximized“.

Go and run the application.

  • Create few Plans
  • Edit some plans
  • Close the application and try playing around with the controls.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.