C \ # Esc 를 누 르 고 대화 상 자 를 종료 합 니 다.

1. 대화 상 자 를 불 러 올 때 KeyPreview 속성 을 true 로 설정 합 니 다.
private void Form2_Load(object sender, EventArgs e)
{
    this.KeyPreview = true;
}

2. KeyPress 함수 에서 "Esc" 에 응답 합 니 다.
private void Form2_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == (char)Keys.Escape)
    {
        this.Close();
    }
}

좋은 웹페이지 즐겨찾기