Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original. |
Traducción
Original
|
DataGridViewCell.EditType (Propiedad)
Obtiene el tipo del control de edición hospedado de la celda.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
Un tipo de celda derivado reemplaza esta propiedad para devolver el tipo de su control de edición hospedado. Si la celda no tiene un control de edición, como sucede con DataGridViewButtonCell, la propiedad EditType devuelve null.
En el ejemplo de código siguiente se muestra cómo reemplazar la propiedad EditType en una clase CalendarCell derivada de DataGridViewTextBoxCell. Este ejemplo forma parte de un ejemplo de código más extenso que se proporciona en Cómo: Alojar controles en celdas DataGridView de formularios Windows Forms.
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; } } }
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.