92. MenuStrip / ContextMenuStrip / StatusStrip / 모달 폼 / 모달리스 폼
.NET프로그래밍/WinForm 2009. 8. 20. 18:31 |
==> Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyWinForms
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
==============================================================================================
==> MainForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void 끝내기ToolStripMenuItem_Click(object sender, EventArgs e)
{
// 현재 프로그램 종료
Application.Exit();
}
private void miAbout_Click(object sender, EventArgs e)
{
// 모달 폼 : 현재 창을 닫아야지만, 메인으로 이동 가능
FrmAbout fa = new FrmAbout();
fa.ShowDialog();
}
private void miButton_Click(object sender, EventArgs e)
{
// 모달리스 폼 : 독립적인 하나의 폼
MyWinForms.Controls.FrmButton fb = new MyWinForms.Controls.FrmButton();
fb.MdiParent = this; // MDI 컨테이너를 현재 폼(메인)으로 설정
fb.Show();
}
private void mnuHelp_Load(object sender, EventArgs e)
{
}
#region 컨텍스트메뉴
private void cmsAbout_Click(object sender, EventArgs e)
{
//FrmAbout fa = new FrmAbout();
//fa.ShowDailog();
miAbout_Click(null, null); // 재 사용
}
private void cmsExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
#endregion
}
}
==============================================================================================
==> FrmAbout.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms
{
public partial class FrmAbout : Form
{
public FrmAbout()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
// 현재 폼 닫기
this.Close();
}
private void lblTitle_Click(object sender, EventArgs e)
{
}
}
}
==============================================================================================
==> FrmButton.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms.Controls
{
public partial class FrmButton : Form
{
public FrmButton()
{
InitializeComponent();
}
}
}
< 실행결과 >
==> 모달 폼
==> 모달리스 폼
==> 컨텍스트메뉴
'.NET프로그래밍 > WinForm' 카테고리의 다른 글
95. 체크박스(CheckBox) / 라디오버튼(RadioButton) (0) | 2009.08.21 |
---|---|
94. 버튼 / 레이블 / 텍스트박스 (Button / Label / TextBox) (0) | 2009.08.21 |
(테스트) 인터넷쇼핑몰 - WinForm을 이용하여 회원으로부터 회원번호, 주문상품코드, 주문수량을 입력받아 결과를 출력하는 프로그램 (0) | 2009.08.21 |
93. WinForm을 이용한 체중 관리 프로그램 (0) | 2009.08.20 |
91. WinForm 시작 - HelloWorld (0) | 2009.08.20 |