94. 버튼 / 레이블 / 텍스트박스 (Button / Label / TextBox)
.NET프로그래밍/WinForm 2009. 8. 21. 16:36 |
==> MainForm.cs
#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
private void miLabel_Click(object sender, EventArgs e)
{
MyWinForms.Controls.FrmButtonLaberlTextBox blt = new MyWinForms.Controls.FrmButtonLaberlTextBox();
blt.MdiParent = this;
blt.Show();
}
private void FrmCheckBoxRadioButton_Click(object sender, EventArgs e)
{
MyWinForms.Controls.FrmCheckBoxRadioButton cbrb = new MyWinForms.Controls.FrmCheckBoxRadioButton();
cbrb.MdiParent = this;
cbrb.Show();
}
==============================================================================================
==> FrmButtonLaberlTextBox.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 FrmButtonLaberlTextBox : Form
{
public FrmButtonLaberlTextBox()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
int kor = Convert.ToInt32(txtKor.Text);
int eng = Int32.Parse(txtEng.Text);
int tot = kor + eng;
// mbox ==> MessageBox의 코드조각이다. cw ==> Console.WriteLine과 같은 코드조각이다.
MessageBox.Show(String.Format("{0} + {1} = {2}", kor, eng, tot));
btnCancel_Click(null, null); // 재 호출
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.txtKor.Text = "";
this.txtEng.Text = String.Empty;
txtKor.Focus();
}
private void txtKor_KeyDown(object sender, KeyEventArgs e)
{
// 두번째 매개변수 e.KeyCode로 키보드값을 반환
if (e.KeyCode == Keys.Enter)
{
this.txtEng.Focus(); // 포커스 부여
}
}
private void txtEng_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.btnOK_Click(null, null); // 확인 버튼 클릭
}
}
}
}
< 실행결과 >
'.NET프로그래밍 > WinForm' 카테고리의 다른 글
96. 마스크(Mask) / 리치(Rich) / 읽기전용(ReadOnly) 텍스트박스(TextBox) (0) | 2009.08.24 |
---|---|
95. 체크박스(CheckBox) / 라디오버튼(RadioButton) (0) | 2009.08.21 |
(테스트) 인터넷쇼핑몰 - WinForm을 이용하여 회원으로부터 회원번호, 주문상품코드, 주문수량을 입력받아 결과를 출력하는 프로그램 (0) | 2009.08.21 |
93. WinForm을 이용한 체중 관리 프로그램 (0) | 2009.08.20 |
92. MenuStrip / ContextMenuStrip / StatusStrip / 모달 폼 / 모달리스 폼 (0) | 2009.08.20 |