DataGridView.EditingControl Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar kontrollen som hanteras av den aktuella cellen om en cell med en redigeringskontroll är i redigeringsläge.
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
Egenskapsvärde
Värd Control för den aktuella cellen.
- Attribut
Exempel
I följande kodexempel visas hur du använder den här egenskapen i en åsidosatt metod av en anpassad celltyp. I exemplet hämtas en referens till redigeringskontrollen, omvandlas till en anpassad redigeringskontrolltyp och fylls sedan i med cellens aktuella värde.
Det här exemplet är en del av ett större exempel i How to: Host Controls in Windows Forms 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
Kommentarer
Om cellen inte är i redigeringsläge eller om celltypen inte rymmer en redigeringskontroll returnerar nullden här egenskapen .