블로그 이미지
따시쿵

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2015. 5. 7. 15:43 C#

MDI(Multiple Document Interface) 를 만드는 예제입니다.


MDI 만드는 방법


1. 일반 폼에 isMdiContainer 속성값을 true 로 설정함으로써 폼 컨테이너로 설정


실행화면


프로그램 작성

        #region Form2
        Form2 f2 = null;
        private void form2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (f2 == null)
            {
                f2 = new Form2();
                f2.MdiParent = this;
                f2.FormClosed += new FormClosedEventHandler(f2_FormClosed);
                f2.Show();
            }
            else
                f2.Activate();
        }

        void f2_FormClosed(object sender, FormClosedEventArgs e)
        {
            f2 = null;
        }
        #endregion

        #region Form3
        private void form3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.MdiParent = this;
            f3.Show();
        }
        #endregion


2. 폼을 만드는 시점에 MDI 부모 폼 으로 폼 자체를 만듦


실행화면


프로그램 작성

        private void form1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 f1 = new Form1();
            f1.MdiParent = this;
            f1.Show();
        }

        private void form2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.MdiParent = this;
            f2.Show();
            f2.WindowState = FormWindowState.Maximized;
        }


'C#' 카테고리의 다른 글

초단위 시간 경과 보이기  (0) 2015.05.12
로그인 창  (0) 2015.05.08
데이타베이스 라이브러리  (0) 2015.04.22
BackgroundWorker class  (0) 2015.03.02
텍스트 로그 파일 라이브러리 - 3  (0) 2015.02.21
posted by 따시쿵