DisplayFormatAttribute.ApplyFormatInEditMode 屬性

定義

取得或設定值,這個值指出當資料欄位處於編輯模式時,DataFormatString 屬性指定的格式化字串是否套用至欄位值。

public:
 property bool ApplyFormatInEditMode { bool get(); void set(bool value); };
public bool ApplyFormatInEditMode { get; set; }
member this.ApplyFormatInEditMode : bool with get, set
Public Property ApplyFormatInEditMode As Boolean

屬性值

如果格式化字串會套用至編輯模式下的欄位值,則為 true,否則為 false。 預設為 false

範例

下列範例示範如何在數據欄位處於編輯模式時,使用 ApplyFormatInEditMode 屬性來設定日期資訊的顯示格式。 要用於數據欄位的數據欄位格式是藉由設定 DataFormatString 屬性來指定。

// Display date data field in the short format 11/12/08.
// Also, apply format in edit mode.
[DisplayFormat(ApplyFormatInEditMode=true, DataFormatString = "{0:d}")]
public object SellStartDate;
' Display date data field in the short format such as 11/12/08.
' Also, apply format in edit mode.
<DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="{0:d}")> _
Public SellStartDate As Object

備註

根據預設,只有當數據綁定控件處於只讀模式時,屬性所 DataFormatString 指定的格式字串才會套用至域值。

適用於