DataGridViewCell.EditType DataGridViewCell.EditType DataGridViewCell.EditType DataGridViewCell.EditType Property

정의

셀의 호스팅된 편집 컨트롤의 형식을 가져옵니다.Gets the type of the cell's hosted editing control.

public:
 virtual property Type ^ EditType { Type ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual Type EditType { get; }
member this.EditType : Type
Public Overridable ReadOnly Property EditType As Type

속성 값

Type 형식을 나타내는 DataGridViewTextBoxEditingControl입니다.A Type representing the DataGridViewTextBoxEditingControl type.

예제

다음 코드 예제에는 재정의 하는 방법을 보여 줍니다.는 EditType 의 속성을 CalendarCell 에서 파생 된 클래스 DataGridViewTextBoxCell합니다.The following code example demonstrates how to override the EditType property in a CalendarCell class that derives from DataGridViewTextBoxCell. 이 예제는 다음과 같은 방법으로 제공 되는 더 큰 코드 예제의 일부입니다. Windows Forms DataGridView 셀의 호스트 컨트롤입니다.This example is part of a larger code example provided in How to: Host Controls in Windows Forms DataGridView Cells.

public class CalendarCell : DataGridViewTextBoxCell
{

    public CalendarCell()
        : base()
    {
        // Use the short date format.
        this.Style.Format = "d";
    }

    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 override Type EditType
    {
        get
        {
            // Return the type of the editing control that CalendarCell uses.
            return typeof(CalendarEditingControl);
        }
    }

    public override Type ValueType
    {
        get
        {
            // Return the type of the value that CalendarCell contains.
            
            return typeof(DateTime);
        }
    }

    public override object DefaultNewRowValue
    {
        get
        {
            // Use the current date and time as the default value.
            return DateTime.Now;
        }
    }
}
Public Class CalendarCell
    Inherits DataGridViewTextBoxCell

    Public Sub New()
        ' Use the short date format.
        Me.Style.Format = "d"
    End Sub

    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

    Public Overrides ReadOnly Property EditType() As Type
        Get
            ' Return the type of the editing control that CalendarCell uses.
            Return GetType(CalendarEditingControl)
        End Get
    End Property

    Public Overrides ReadOnly Property ValueType() As Type
        Get
            ' Return the type of the value that CalendarCell contains.
            Return GetType(DateTime)
        End Get
    End Property

    Public Overrides ReadOnly Property DefaultNewRowValue() As Object
        Get
            ' Use the current date and time as the default value.
            Return DateTime.Now
        End Get
    End Property

End Class

설명

파생된 셀 형식을 해당 호스팅된 편집 컨트롤의 형식을 반환 하도록이 속성을 재정의 합니다.A derived cell type overrides this property to return the type of its hosted editing control. 셀 편집 컨트롤이 없는 경우와 마찬가지로 DataGridViewButtonCellEditType 속성이 반환 null.If the cell does not have an editing control, as with DataGridViewButtonCell, the EditType property returns null.

적용 대상

추가 정보