IDataGridViewEditingControl.EditingControlFormattedValue 属性

定义

获取或设置编辑器正在修改的单元格的格式化值。

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

属性值

一个 Object,表示单元格的格式化值。

示例

下面的代码示例提供了此成员的实现。 此示例是如何:在 DataGridView 单元格中托管控件Windows 窗体中提供的更大示例的一部分。

// 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

注解

格式化的值表示在控件的用户界面中显示的值。 格式化的值在绝对值甚至数据类型上可能与控件中包含的实际值不同。

适用于

另请参阅