Bahasa

DataGridView.EditingControl Properti

Definisi

Mendapatkan kontrol yang dihosting oleh sel saat ini, jika sel dengan kontrol pengeditan berada dalam mode edit.

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)]
public System.Windows.Forms.Control? EditingControl { get; }
[<System.ComponentModel.Browsable(false)>]
member this.EditingControl : System.Windows.Forms.Control
Public ReadOnly Property EditingControl As Control

Nilai Properti

Dihosting Control oleh sel saat ini.

Atribut

Contoh

Contoh kode berikut mengilustrasikan cara menggunakan properti ini dalam metode penggantian tipe sel kustom. Dalam contoh, referensi ke kontrol pengeditan diambil, ditransmisikan ke jenis kontrol pengeditan kustom, lalu diisi dengan nilai sel saat ini.

Contoh ini adalah bagian dari contoh yang lebih besar yang tersedia di Cara: Kontrol Host di Formulir Windows DataGridView Cells.

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

Keterangan

Jika sel tidak dalam mode edit atau tipe sel tidak mengakomodasi kontrol pengeditan, properti ini mengembalikan null.

Berlaku untuk

Lihat juga