DataGridView.EditingControlShowing 이벤트

정의

셀 편집을 위한 컨트롤이 표시될 때 발생합니다.

public:
 event System::Windows::Forms::DataGridViewEditingControlShowingEventHandler ^ EditingControlShowing;
public event System.Windows.Forms.DataGridViewEditingControlShowingEventHandler EditingControlShowing;
public event System.Windows.Forms.DataGridViewEditingControlShowingEventHandler? EditingControlShowing;
member this.EditingControlShowing : System.Windows.Forms.DataGridViewEditingControlShowingEventHandler 
Public Custom Event EditingControlShowing As DataGridViewEditingControlShowingEventHandler 

이벤트 유형

예제

다음 코드 예제에서는이 이벤트를 처리 하는 방법을 보여 줍니다는 BackColor 현재 셀의 속성입니다. 이 예제를 실행 하려면 코드를 포함 하는 폼에 붙여 넣습니다를 DataGridView 라는 dataGridView1 있는지 확인 합니다 EditingControlShowing 이벤트는 이벤트 처리기를 사용 하 여 연결 합니다.

private void dataGridView1_EditingControlShowing(object sender, 
    DataGridViewEditingControlShowingEventArgs e)
{
    e.CellStyle.BackColor = Color.Aquamarine;
}
Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, _
    ByVal e As DataGridViewEditingControlShowingEventArgs) _
    Handles dataGridView1.EditingControlShowing

    e.CellStyle.BackColor = Color.Aquamarine

End Sub

설명

셀이 편집 모드로 전환되면 이 이벤트를 처리하여 편집 컨트롤의 사용자 지정 초기화를 수행할 수 있습니다. 컨트롤의 표시 특성을 사용자 지정하려면 속성에서 반환 DataGridViewEditingControlShowingEventArgs.CellStyle 된 개체의 속성을 설정합니다. 다른 초기화를 수행하려면 속성 값을 DataGridViewEditingControlShowingEventArgs.Control 특정 컨트롤 형식으로 캐스팅하고 멤버에 직접 액세스합니다. 예를 들어 이벤트를 처리 EditingControlShowing 하여 편집 컨트롤의 이벤트에 이벤트 처리기를 연결할 수 있습니다.

참고

컨트롤은 DataGridView 한 번에 하나의 편집 컨트롤을 호스트하고 편집 간에 셀 형식이 변경되지 않을 때마다 편집 컨트롤을 다시 사용합니다. 따라서 편집 컨트롤에 이벤트 처리기를 연결할 때 동일한 처리기를 여러 번 연결하지 않도록 주의해야 합니다. 이 문제를 방지하려면 이벤트에 처리기를 연결하기 전에 이벤트에서 처리기를 제거합니다. 이렇게 하면 처리기가 이벤트에 이미 연결되어 있는 경우 중복을 방지하지만, 그렇지 않으면 아무런 영향을 주지 않습니다. 자세한 내용은 클래스 개요의 예제 코드를 DataGridViewComboBoxEditingControl 참조하세요.

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

적용 대상

추가 정보