Share via


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,表示儲存格的格式化值。

範例

下列程式碼範例提供這個成員的實作。 此範例是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

備註

格式化的值代表值,因為它顯示在控制項的使用者介面中。 格式化的值在絕對值中可能不同,甚至資料類型與 控制項中包含的實際值不同。

適用於

另請參閱