MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集
入力範囲を指定する

GcTimeSpanCellTypeクラスのMinValueプロパティで最小値を、MaxValueプロパティで最大値を指定できます。最大値に1日以上の値を設定することで、24時間以上の値を入力し、表示できます。

private void Form1_Load(object sender, EventArgs e)
{
    GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType gcTimeSpan1 = new GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType();
    gcTimeSpan1.SideButtons.Add(new GrapeCity.Win.Spread.InputMan.CellType.SpinButtonInfo());
    // 入力フィールドの設定
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourFieldInfo timeSpanHourField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourFieldInfo() { Digits = 2 };
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralFieldInfo timeSpanLiteralField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralFieldInfo() { Text = ":" };
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteFieldInfo timeSpanMinuteField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteFieldInfo() { Digits = 2 };
    gcTimeSpan1.Fields.Clear();
    gcTimeSpan1.Fields.Add(timeSpanHourField1);
    gcTimeSpan1.Fields.Add(timeSpanLiteralField1);
    gcTimeSpan1.Fields.Add(timeSpanMinuteField1);
    // 表示フィールドの設定
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourDisplayFieldInfo timeSpanHourDisplayField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourDisplayFieldInfo() { Digits = 2 };
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo timeSpanLiteralDisplayField2 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo() { Text = "時間" };
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteDisplayFieldInfo timeSpanMinuteDisplayField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteDisplayFieldInfo() { Digits = 2 };
    GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo timeSpanLiteralDisplayField3 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo() { Text = "分" };
    gcTimeSpan1.DisplayFields.Add(timeSpanHourDisplayField1);
    gcTimeSpan1.DisplayFields.Add(timeSpanLiteralDisplayField2);
    gcTimeSpan1.DisplayFields.Add(timeSpanMinuteDisplayField1);
    gcTimeSpan1.DisplayFields.Add(timeSpanLiteralDisplayField3);
    // 入力可能最小値(24時間以上)を設定します。
    gcTimeSpan1.MinValue = new TimeSpan(1, 0, 0, 0);
    // 入力可能最大値(72時間未満)を設定します。
    gcTimeSpan1.MaxValue = new TimeSpan(2, 23, 59, 59);
            
    fpSpread1.Sheets[0].Cells[1, 1].CellType = gcTimeSpan1;
}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim gcTimeSpan1 As New GrapeCity.Win.Spread.InputMan.CellType.GcTimeSpanCellType()
    gcTimeSpan1.SideButtons.Add(New GrapeCity.Win.Spread.InputMan.CellType.SpinButtonInfo())
    ' 入力フィールドの設定
    Dim timeSpanHourField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourFieldInfo() With {
        .Digits = 2
    }
    Dim timeSpanLiteralField2 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralFieldInfo() With {
        .Text = ":"
    }
    Dim timeSpanMinuteField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteFieldInfo() With {
        .Digits = 2
    }
    gcTimeSpan1.Fields.Clear()
    gcTimeSpan1.Fields.Add(timeSpanHourField1)
    gcTimeSpan1.Fields.Add(timeSpanLiteralField2)
    gcTimeSpan1.Fields.Add(timeSpanMinuteField1)
    ' 表示フィールドの設定
    Dim timeSpanHourDisplayField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanHourDisplayFieldInfo() With {
        .Digits = 2
    }
    Dim timeSpanLiteralDisplayField2 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo() With {
        .Text = "時間"
    }
    Dim timeSpanMinuteDisplayField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanMinuteDisplayFieldInfo() With {
        .Digits = 2
    }
    Dim timeSpanLiteralDisplayField3 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.TimeSpanLiteralDisplayFieldInfo() With {
        .Text = "分"
    }
    gcTimeSpan1.DisplayFields.Add(timeSpanHourDisplayField1)
    gcTimeSpan1.DisplayFields.Add(timeSpanLiteralDisplayField2)
    gcTimeSpan1.DisplayFields.Add(timeSpanMinuteDisplayField1)
    gcTimeSpan1.DisplayFields.Add(timeSpanLiteralDisplayField3)
    ' 入力可能最小値(24時間以上)を設定します。
    gcTimeSpan1.MinValue = New TimeSpan(1, 0, 0, 0)
    ' 入力可能最大値(72時間未満)を設定します。
    gcTimeSpan1.MaxValue = New TimeSpan(2, 23, 59, 59)
    FpSpread1.Sheets(0).Cells(1, 1).CellType = gcTimeSpan1
End Sub

 

 


© MESCIUS inc. All rights reserved.