IDataGridViewEditingControl.EditingControlFormattedValue Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the formatted value of the cell being modified by the editor.
public:
property System::Object ^ EditingControlFormattedValue { System::Object ^ get(); void set(System::Object ^ value); };
public object EditingControlFormattedValue { get; set; }
member this.EditingControlFormattedValue : obj with get, set
Public Property EditingControlFormattedValue As Object
Property Value
An Object that represents the formatted value of the cell.
Examples
The following code example provides an implementation of this member. This example is part of a larger example available in How to: Host Controls in Windows Forms DataGridView Cells.
// Implements the IDataGridViewEditingControl.EditingControlFormattedValue
// property.
public object EditingControlFormattedValue
{
get
{
return this.Value.ToShortDateString();
}
set
{
if (value is String)
{
try
{
// This will throw an exception of the string is
// null, empty, or not in the format of a date.
this.Value = DateTime.Parse((String)value);
}
catch
{
// In the case of an exception, just use the
// default value so we're not left with a null
// value.
this.Value = DateTime.Now;
}
}
}
}
Public Property EditingControlFormattedValue() As Object _
Implements IDataGridViewEditingControl.EditingControlFormattedValue
Get
Return Me.Value.ToShortDateString()
End Get
Set(ByVal value As Object)
Try
' This will throw an exception of the string is
' null, empty, or not in the format of a date.
Me.Value = DateTime.Parse(CStr(value))
Catch
' In the case of an exception, just use the default
' value so we're not left with a null value.
Me.Value = DateTime.Now
End Try
End Set
End Property
Remarks
The formatted value represents the value as it is displayed in the control's user interface. The formatted value may be different in absolute value and even data type from the actual value contained in the control.