public frm_main() // private constructor (singleton desPattern) { InitializeComponent(); if (_instance == null) { _instance = this; } //file, prodcuts, users this.productsToolStripMenuItem.Enabled = false; this.usersToolStripMenuItem.Enabled = false; this.backUpDbToolStripMenuItem.Enabled = false; this.restoreDbBackupToolStripMenuItem.Enabled = false; // used to update the textbox of current time and date Timer tmr; // timer to update the txt_dateTime textbox tmr = new Timer(); tmr.Interval = 1000; tmr.Tick += tmr_Tick; tmr.Enabled = true; }
static void frm_FormClosed(object sender, FormClosedEventArgs e) { // for security purposes // dispose the form object on closing the form, just to make sure that no other forms are using this object _instance = null; }