DateTimePicker.Text DateTimePicker.Text DateTimePicker.Text DateTimePicker.Text Property

定義

取得或設定這個控制項的相關文字。Gets or sets the text associated with this control.

public:
 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public override string Text { get; set; }
member this.Text : string with get, set
Public Overrides Property Text As String

屬性值

字串,表示和這個控制項相關的文字。A string that represents the text associated with this control.

備註

這個屬性所傳回的字串,相當於已Value套用適當格式設定或自訂格式的屬性。The string returned by this property is equivalent to the Value property with the appropriate formatting or custom formatting applied. 例如,如果Value將屬性設定為 "dddd,MMMM dd, CustomFormat yyyy",而屬性設定為 06/01/2001 12:00:00 AM,則Text屬性值為 "星期五,6月01日,2001"。For example, if the Value property is set to 06/01/2001 12:00:00 AM while the CustomFormat property is set to "dddd, MMMM dd, yyyy", the Text property value is "Friday, June 01, 2001".

設定這個屬性時,字串必須可轉換成DateTime類別的實例。When setting this property, the string must be convertible to an instance of the DateTime class. 您可以定義自訂格式,以產生無法轉換成有效DateTime值的字串。It is possible to define a custom format that results in a string that cannot be converted to a valid DateTime value. 因此,從Text屬性傳回的字串如果傳回Text給屬性,可能會導致錯誤。Because of this, the string returned from the Text property might cause an error if it is passed back to the Text property. 如果無法將字串轉換成日期/時間值, DateTime類別FormatException會擲回。If the string cannot be converted to a date/time value, the DateTime class throws a FormatException.

適用於

另請參閱