using System;
using System.Windows.Forms;

namespace Infragistics_TabbedMdiTest
{
    public partial class ChildForm : Form
    {
        public ChildForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FormUtils.Reopen(this, MdiParent as MdiForm);
        }

        private void ChildForm_Load(object sender, EventArgs e)
        {
            label1.Text = string.Format("Opened at {0}", DateTime.Now);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Text = Guid.NewGuid().ToString();
        }

        public void ResetForm()
        {
            //simulate form cloasing
            System.ComponentModel.CancelEventArgs ce = new System.ComponentModel.CancelEventArgs(false);
            this.OnClosing(ce);
           //if you do not have any validation code in the Cosing event you could skip following if clauses 
            if (ce.Cancel)
                return;
            FormClosingEventArgs fce = new FormClosingEventArgs(CloseReason.UserClosing, false);
            this.OnFormClosing(fce);
            //if you do not have any validation code in the Cosing event you could skip following if clauses 
            if (fce.Cancel)
                return;
            this.OnClosed(new EventArgs());
            this.OnFormClosed(new FormClosedEventArgs(CloseReason.UserClosing));
            this.OnDeactivate(new EventArgs());

            //simulate form reopaning
            EventArgs e = new EventArgs();
            this.OnHandleCreated(e);
            this.OnBindingContextChanged(e);
            this.OnLoad(e);
            this.OnVisibleChanged(e);
            this.OnActivated(e);
            this.OnShown(e);

            //this.Refresh();
            //this.Invalidate();
        }

       
    }

}
