==> 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 Sample.FrmKeyboard());
        }
    }
}




==============================================================================================




==> FrmKeyboard.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.Sample
{
    public partial class FrmKeyboard : Form
    {
        public FrmKeyboard()
        {
            InitializeComponent();
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            // 엔터키를 타이핑했을 때 다음 텍스트박스로 이동
            if (e.KeyChar == (char)Keys.Enter)
            {
                textBox2.Focus();
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            // 엔터키 입력시 확인 버튼으로 포커스
            if (e.KeyCode == Keys.Enter)
            {
                button1.Focus();
            }
        }
    }
}





< 실행결과 >

--> '국어'점수의 "TextBox"에 텍스트(100) 입력 후, 엔터키를 타이핑했을 때 다음 텍스트박스로 이동





--> '영어'점수의 "TextBox"에 텍스트(90) 입력 후, 엔터키 입력시 "확인" 버튼으로 포커스() 맞춰짐.





Posted by holland14
: