DataGridView.EditingControl 속성

정의

편집 컨트롤이 있는 셀이 편집 모드인 경우 현재 셀에 의해 호스팅되는 컨트롤을 가져옵니다.

public:
 property System::Windows::Forms::Control ^ EditingControl { System::Windows::Forms::Control ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Control EditingControl { get; }
[<System.ComponentModel.Browsable(false)>]
member this.EditingControl : System.Windows.Forms.Control
Public ReadOnly Property EditingControl As Control

속성 값

Control

현재 셀에 의해 호스팅되는 Control입니다.

특성

예제

다음 코드 예제에서는 사용자 지정 셀 형식의 재정의 된 메서드에서이 속성을 사용 하는 방법을 보여 줍니다. 이 예제에서는 편집 컨트롤에 대한 참조를 검색하고 사용자 지정 편집 컨트롤 형식으로 캐스팅한 다음 셀의 현재 값으로 채워집니다.

이 예제는에서 사용할 수 있는 보다 큰 예제의 일부 방법: Windows Forms DataGridView 셀에서 컨트롤을 호스트합니다.

public override void InitializeEditingControl(int rowIndex, object 
    initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
    // Set the value of the editing control to the current cell value.
    base.InitializeEditingControl(rowIndex, initialFormattedValue, 
        dataGridViewCellStyle);
    CalendarEditingControl ctl = 
        DataGridView.EditingControl as CalendarEditingControl;
    // Use the default row value when Value property is null.
    if (this.Value == null)
    {
        ctl.Value = (DateTime)this.DefaultNewRowValue;
    }
    else
    {
        ctl.Value = (DateTime)this.Value;
    }
}
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
    ByVal initialFormattedValue As Object, _
    ByVal dataGridViewCellStyle As DataGridViewCellStyle)

    ' Set the value of the editing control to the current cell value.
    MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _
        dataGridViewCellStyle)

    Dim ctl As CalendarEditingControl = _
        CType(DataGridView.EditingControl, CalendarEditingControl)

    ' Use the default row value when Value property is null.
    If (Me.Value Is Nothing) Then
        ctl.Value = CType(Me.DefaultNewRowValue, DateTime)
    Else
        ctl.Value = CType(Me.Value, DateTime)
    End If
End Sub

설명

셀이 편집 모드가 아니거나 셀 형식이 편집 컨트롤을 수용하지 않는 경우 이 속성은 반환됩니다 null.

적용 대상

추가 정보