==> 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); // 확인 버튼 클릭
            }
        }
    }
}


< 실행결과 >








Posted by holland14
: