PowerTools InputMan for Windows Forms 8.0J
DisplayFields プロパティ (GcDate)
使用例 

GcDate コントロールの表示フィールドを取得します。
構文
Public Shadows ReadOnly Property DisplayFields As DateTimeDisplayFieldCollection
public new DateTimeDisplayFieldCollection DisplayFields {get;}

プロパティ値

表示フィールドのコレクションを示す GrapeCity.Win.Editors.Fields.DateDisplayFieldCollection オブジェクト。
解説
このプロパティは、このコントロールに入力フォーカスがないときの Value の表示方法を決定します。
使用例
次のサンプルコードは、代替テキスト設定と特定の表示フィールドを持つ GcDate コントロールを作成します。また、AlternateText プロパティと DisplayFields プロパティも使用しています。
//  Please use the following namespace
//  using System.Windows.Forms;
//  using GrapeCity.Win.Editors;
//  using System.Drawing;

public void SetAlternateTextSettings()
{
    // Creates an instance of a GcDate control.
    GcDate gcDate1 = new GcDate();

    // Clear the default Fields
    gcDate1.Fields.Clear();

    // Sets the text of the DisplayNull property.
    // The text will displayed when the GcDate control lost focus.
    gcDate1.AlternateText.DisplayNull.Text = "Please Input here";
    // Sets the ForeColor of the DisplayNull property.
    // The text will displayed with this color.
    gcDate1.AlternateText.DisplayNull.ForeColor = Color.Red;
    // Sets the text of the Null property.
    // The text will displayed when the GcDate control got focus.
    gcDate1.AlternateText.Null.Text = "Now the value is null";
    // Sets the ForeColor of the Null property.
    // The text will displayed with this color.
    gcDate1.AlternateText.Null.ForeColor = Color.Blue;
    // Sets the DisplayEmptyEra.Text to a string for displaying when the value out of the range of Era.
    gcDate1.AlternateText.DisplayEmptyEra.Text = "Value is out of Era range.";
    // Sets the EmptyEra.Text to a string with a special format. 
    // The text will display the date time value according to the format "yyy/MM/dd"
    // When the value is out of the range of era, the text will shown like "1009/07/02".
    gcDate1.AlternateText.EmptyEra.Text = "{[yyy/MM/dd]}";

    // Defines the fields by format string.
    gcDate1.Fields.AddRange(@"ggg ee年MM月dd日");

    // Defines the display fields by format string.
    gcDate1.DisplayFields.AddRange(@"gg e年M月d日");

    // Set Font of all DateLiteralField instances.
    List<GrapeCity.Win.Editors.Fields.DateLiteralField> literalFields = gcDate1.Fields.FindAll<GrapeCity.Win.Editors.Fields.DateLiteralField>();
    foreach (GrapeCity.Win.Editors.Fields.DateLiteralField field in literalFields)
    {
        field.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
    }

    // Sets the value of the GcDate to a DateTime value that out of Era.
    gcDate1.Value = new System.DateTime(1009, 7, 2);
}
'  Please use the following namespace
'  Imports System.Windows.Forms;
'  Imports GrapeCity.Win.Editors;
'  Imports System.Drawing;

Public Sub SetAlternateTextSettings()
    ' Creates an instance of a GcDate control.
    Dim GcDate1 As New GcDate()

    ' Clear the default Fields
    GcDate1.Fields.Clear()

    ' Sets the text of the DisplayNull property.
    ' The text will displayed when the GcDate control lost focus.
    GcDate1.AlternateText.DisplayNull.Text = "Please Input here"
    ' Sets the ForeColor of the DisplayNull property.
    ' The text will displayed with this color.
    GcDate1.AlternateText.DisplayNull.ForeColor = Color.Red
    ' Sets the text of the Null property.
    ' The text will displayed when the GcDate control got focus.
    GcDate1.AlternateText.Null.Text = "Now the value is null"
    ' Sets the ForeColor of the Null property.
    ' The text will displayed with this color.
    GcDate1.AlternateText.Null.ForeColor = Color.Blue
    ' Sets the DisplayEmptyEra.Text to a string for displaying when the value out of the range of Era.
    GcDate1.AlternateText.DisplayEmptyEra.Text = "Value is out of Era range."
    ' Sets the EmptyEra.Text to a string with a special format. 
    ' The text will display the date time value according to the format "yyy/MM/dd"
    ' When the value is out of the range of era, the text will shown like "1009/07/02".
    GcDate1.AlternateText.EmptyEra.Text = "{[yyy/MM/dd]}"

    ' Defines the fields by format string.
    GcDate1.Fields.AddRange("ggg ee年MM月dd日")

    ' Defines the display fields by format string.
    GcDate1.DisplayFields.AddRange("gg e年M月d日")

    ' Set Font of all DateLiteralField instances.
    Dim literalFields As List(Of GrapeCity.Win.Editors.Fields.DateLiteralField) = GcDate1.Fields.FindAll(Of GrapeCity.Win.Editors.Fields.DateLiteralField)()
    For Each field As GrapeCity.Win.Editors.Fields.DateLiteralField In literalFields
        field.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134)
    Next

    ' Sets the value of the GcDate to a DateTime value that out of Era.
    GcDate1.Value = New System.DateTime(1009, 7, 2)
End Sub
参照

GcDate クラス
GcDate メンバ

 

 


© 2004-2015 GrapeCity inc. All rights reserved.