■ 컨트롤의 포커스를 이동하는 방법을 보여준다.
▶ 예제 코드 (C#)
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 |
using System.Windows.Forms; #region 텍스트 박스 키 PRESS 처리하기 - textBox_KeyPress(sender, e) /// <summary> /// 텍스트 박스 키 PRESS 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void textBox_KeyPress(object sender, KeyPressEventArgs e) { if(e.KeyChar == (char)Keys.Enter) { e.Handled = true; Control control = GetNextControl(sender as Control, true); if(control != null) { control.Focus(); } } } #endregion |
※ Form 클래스를 상속받은 클래스 내에서 정의한 것으로 가정한다.