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

コントロールの値がNothingあるいは時間間隔0の場合に表示する文字列に関する設定を取得します。
構文
Public ReadOnly Property AlternateText As TimeSpanAlternateText
public TimeSpanAlternateText AlternateText {get;}

プロパティ値

文字列の設定を表すTimeSpanAlternateTextオブジェクト。
解説
このプロパティを設定すると、編集モードおよび表示モードにおいてコントロールの値がTimeSpanAlternateText.ZeroまたはTimeSpanAlternateText.Nullのときに、設定したテキストが代わりに表示されます。
使用例
代替テキストと表示フィールドを設定した GcTimeSpan コントロールを作成するコード例を次に示します。この例では他に DisplayFields と AlternateText プロパティを使用しています。
//  Please use the following namespace
//  using System.Windows.Forms;
//  using GrapeCity.Win.Editors;
//  using System.Drawing;

public void SetAlternateTextSettings()
{
    // Creates an instance of a GcTimeSpan control.
    GcTimeSpan gcTimeSpan1 = new GcTimeSpan();
    // Clear the default DisplayFields
    gcTimeSpan1.DisplayFields.Clear();
    // Sets the text of the DisplayNull property.
    // The text will displayed when the GcTimeSpan control lost focus.
    gcTimeSpan1.AlternateText.DisplayNull.Text = "Null";
    // Sets the ForeColor of the DisplayNull property.
    // The text will displayed with this color.
    gcTimeSpan1.AlternateText.DisplayNull.ForeColor = Color.Gray;
    // Sets the text of the Null property.
    // The text will displayed when the GcTimeSpan control got focus.
    gcTimeSpan1.AlternateText.Null.Text = "Please input here";
    // Sets the ForeColor of the Null property.
    // The text will displayed with this color.
    gcTimeSpan1.AlternateText.Null.ForeColor = Color.Gray;
    // Sets the DisplayZero.Text to a string for displaying when the value is zero without the input focus.
    gcTimeSpan1.AlternateText.DisplayZero.Text = "Zero";
    // Sets the Zero.Text to a string for displaying when the value is zero with the input focus.
    gcTimeSpan1.AlternateText.Zero.Text = "Please input here";

    // Defines the display fields.
    gcTimeSpan1.DisplayFields.AddRange(@"h:m:s",0,'.',string.Empty,string.Empty,"-",string.Empty);

    // Sets font of all literal fields.            
    List<TimeSpanLiteralField> literalFields = gcTimeSpan1.Fields.FindAll<TimeSpanLiteralField>();
    foreach (TimeSpanLiteralField 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 GcTimeSpan.
    gcTimeSpan1.Value = TimeSpan.Parse("00:00:00");
}
'  Please use the following namespace
'  Imports System.Windows.Forms;
'  Imports GrapeCity.Win.Editors;
'  Imports System.Drawing;

Public Sub SetAlternateTextSettings()
    ' Creates an instance of a GcTimeSpan control.
    Dim gcTimeSpan1 As New GcTimeSpan()
    ' Clear the default DisplayFields
    gcTimeSpan1.DisplayFields.Clear()
    ' Sets the text of the DisplayNull property.
    ' The text will displayed when the GcTimeSpan control lost focus.
    gcTimeSpan1.AlternateText.DisplayNull.Text = "Null"
    ' Sets the ForeColor of the DisplayNull property.
    ' The text will displayed with this color.
    gcTimeSpan1.AlternateText.DisplayNull.ForeColor = Color.Gray
    ' Sets the text of the Null property.
    ' The text will displayed when the GcTimeSpan control got focus.
    gcTimeSpan1.AlternateText.Null.Text = "Please input here"
    ' Sets the ForeColor of the Null property.
    ' The text will displayed with this color.
    gcTimeSpan1.AlternateText.Null.ForeColor = Color.Gray
    ' Sets the DisplayZero.Text to a string for displaying when the value is zero without the input focus.
    gcTimeSpan1.AlternateText.DisplayZero.Text = "Zero"
    ' Sets the Zero.Text to a string for displaying when the value is zero with the input focus.
    gcTimeSpan1.AlternateText.Zero.Text = "Please input here"

    ' Defines the display fields.
    gcTimeSpan1.DisplayFields.AddRange("h:m:s", 0, "."c, String.Empty, String.Empty, "-", _
     String.Empty)

    ' Sets font of all literal fields.            
    Dim literalFields As List(Of TimeSpanLiteralField) = gcTimeSpan1.Fields.FindAll(Of TimeSpanLiteralField)()
    For Each field As TimeSpanLiteralField 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 GcTimeSpan.
    gcTimeSpan1.Value = TimeSpan.Parse("00:00:00")
End Sub
参照

GcTimeSpan クラス
GcTimeSpan メンバ

 

 


© 2004-2015 GrapeCity inc. All rights reserved.