C#에서 MDI Project(MDI Form)생성하기
생성된 프로젝트에서 Add->New Item을 선택하여 MDIParent를 추가 한다.


그러면 [그림1] 같이 MDIParent 폼이 하나 추가된다.
추가된 MDIParent를 시작 하기 위해서 Program에서 MDiparent를 시작하도록 변경한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | namespace SampleTest{ static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); Application.Run(new MDIParent()); } }} |
그리고 나서 열기 등 동작이 수행될 때 생성하고자 하는 폼을 생성시켜 주면 된다
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 | namespace SampleTest{public partial class MDIParent : Form{private int childFormNumber = 0;public MDIParent(){InitializeComponent();}private void ShowNewForm(object sender, EventArgs e){<span style="background-color: #ff6600;">Form childForm = new Form();</span>childForm.MdiParent = this;childForm.Text = "Window " + childFormNumber++;childForm.Show();}private void OpenFile(object sender, EventArgs e){OpenFileDialog openFileDialog = new OpenFileDialog();openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";if (openFileDialog.ShowDialog(this) == DialogResult.OK){string FileName = openFileDialog.FileName;}}} |
'개발언어 > C#' 카테고리의 다른 글
| C# Form 과 Dialog Box (0) | 2017.08.20 |
|---|---|
| C# windows Form 의 chart control 사용하여 그래프 그리기 (1) | 2017.08.20 |
| Convert int to bool in C# 자료형 변환 (0) | 2017.06.15 |
| C# interface 안에서 Delegate 선언 (0) | 2017.06.14 |
| C#크로스 스레드 작업이 잘못 되었습니다.(delegate,Invoke 사용하기) (0) | 2017.06.14 |