영어로 읽기

다음을 통해 공유


DataGridView.RowEnter 이벤트

정의

행이 입력 포커스를 받고 현재 행이 되기 전에 발생합니다.

public event System.Windows.Forms.DataGridViewCellEventHandler RowEnter;
public event System.Windows.Forms.DataGridViewCellEventHandler? RowEnter;

이벤트 유형

예제

다음 코드 예제에서는 현재 행에 있는 셀의 속성을 변경 BackColor 하려면이 이벤트를 처리 하는 방법을 보여 줍니다. 이 예제에서 배경색은 이벤트에서 설정된 다음, 이벤트에서 로 Empty 다시 설정 RowEnter 됩니다RowLeave. 이 예제를 실행하려면 라는 dataGridView1가 포함된 DataGridView 양식에 코드를 붙여넣고 모든 이벤트가 해당 이벤트 처리기와 연결되어 있는지 확인합니다.

private void dataGridView1_RowEnter(object sender, 
    DataGridViewCellEventArgs e)
{
    for (int i = 0; i < dataGridView1.Rows[e.RowIndex].Cells.Count; i++)
    {
        dataGridView1[i, e.RowIndex].Style.BackColor = Color.Yellow;
    }
}

private void dataGridView1_RowLeave(object sender, 
    DataGridViewCellEventArgs e)
{
    for (int i = 0; i < dataGridView1.Rows[e.RowIndex].Cells.Count; i++)
    {
        dataGridView1[i, e.RowIndex].Style.BackColor = Color.Empty;
    }
}

설명

이 이벤트는 가 처음 로드될 때 DataGridView 와 사용자가 현재 행 이외의 행을 선택할 때 발생합니다.

이 이벤트는 속성이 업데이트되기 CurrentRow 전에 발생합니다. 새로 입력한 행의 인덱스 검색 하려면 사용 된 DataGridViewCellEventArgs.RowIndex 이벤트 처리기 내에서 속성입니다.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

적용 대상

제품 버전
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

추가 정보