GrapeCity SPREAD for Windows Forms 12.0J サンプルコード集
マス目のスタイルを変更する

マス目には、InputBox(入力用の枠)、LiteralBox(リテラル文字)、SeparatorBox(ハイフン)オブジェクトがあり、それぞれのプロパティを使用して、マス目のスタイルを設定できます。

【実行例】

private void Form1_Load(object sender, EventArgs e)
{
    GrapeCity.Win.Spread.InputMan.CellType.GcCharMaskCellType gcCharMask1 = new GrapeCity.Win.Spread.InputMan.CellType.GcCharMaskCellType() { PaintByControl = true, FormatString="9" };
    gcCharMask1.CharBoxSpacing = 2;
    gcCharMask1.CharBoxes.Clear();
    // キャラクターボックスの境界線を作成します。
    GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo borderSingle =
        new GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(new GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.Single, Color.Black));
    GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo borderSingleGray =
        new GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(new GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.Single, Color.OrangeRed));
    GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo borderNone =
        new GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(new GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.None, Color.White));
    // リテラル文字を作成します。
    GrapeCity.Win.Spread.InputMan.CellType.LiteralBoxInfo aLiteralBox = new GrapeCity.Win.Spread.InputMan.CellType.LiteralBoxInfo()
    {
        AutoSize = false,
        Size = new System.Drawing.Size(14, 24),
        ForeColor = Color.Black,
        Text = "〒",
        Border = borderNone
    };
    // 郵便番号の前半3桁用の枠を作成します。
    GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo aInputBoxl = new GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo()
    {
        AutoSize=false,
        Size = new System.Drawing.Size(18, 24),
        ForeColor = Color.Black
    };           
    // ハイフンを作成します。
    GrapeCity.Win.Spread.InputMan.CellType.SeparatorBoxInfo aSeparatorBox = new GrapeCity.Win.Spread.InputMan.CellType.SeparatorBoxInfo()
    {
        AutoSize = false,
        Size = new System.Drawing.Size(10, 24),
        Border = borderNone
    };           
    // 郵便番号の後半4桁用の枠を作成します。
    GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo aInputBoxs = new GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo()
    {
        AutoSize=false,
        Size = new System.Drawing.Size(16, 20),
        ForeColor = Color.Black,
        Border = borderSingleGray
    };           
    // GcCharMask型セルに作成したマス目を追加します。
    gcCharMask1.CharBoxes.Add(aLiteralBox);
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxl.Clone());
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxl.Clone());
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxl.Clone());
    gcCharMask1.CharBoxes.Add(aSeparatorBox);
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxs.Clone());
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxs.Clone());
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxs.Clone());
    gcCharMask1.CharBoxes.Add((GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo)aInputBoxs.Clone());
    // GcCharMask型セルをセルに設定します。           
    fpSpread1.Sheets[0].Cells[1, 1].CellType = gcCharMask1;
}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim gcCharMask1 As New GrapeCity.Win.Spread.InputMan.CellType.GcCharMaskCellType() With {
        .PaintByControl = True,
        .FormatString = "9"
    }
    gcCharMask1.CharBoxSpacing = 2
    gcCharMask1.CharBoxes.Clear()
    ' キャラクターボックスの境界線を作成します。
    Dim borderSingle As New GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(New GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.[Single], Color.Black))
    Dim borderSingleGray As New GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(New GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.[Single], Color.OrangeRed))
    Dim borderNone As New GrapeCity.Win.Spread.InputMan.CellType.CharBoxBorderInfo(New GrapeCity.Win.Spread.InputMan.CellType.Line(GrapeCity.Win.Spread.InputMan.CellType.LineStyle.None, Color.White))
    ' リテラル文字を作成します。
    Dim aLiteralBox As New GrapeCity.Win.Spread.InputMan.CellType.LiteralBoxInfo() With {
        .Size = New System.Drawing.Size(14, 24),
        .ForeColor = Color.Black,
        .Text = "〒",
        .Border = borderNone
    }
    ' 郵便番号の前半3桁用の枠を作成します。
    Dim aInputBoxl As New GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo() With {
        .AutoSize = False,
        .Size = New System.Drawing.Size(18, 24),
        .ForeColor = Color.Black
    }
    ' ハイフンを作成します。
    Dim aSeparatorBox As New GrapeCity.Win.Spread.InputMan.CellType.SeparatorBoxInfo() With {
        .Size = New System.Drawing.Size(10, 24),
        .Border = borderNone
    }
    ' 郵便番号の後半4桁用の枠を作成します。
    Dim aInputBoxs As New GrapeCity.Win.Spread.InputMan.CellType.InputBoxInfo() With {
        .AutoSize = False,
        .Size = New System.Drawing.Size(16, 20),
        .ForeColor = Color.Black,
        .Border = borderSingleGray
    }
    ' GcCharMask型セルに作成したマス目を追加します。
    gcCharMask1.CharBoxes.Add(aLiteralBox)
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxl.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxl.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxl.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(aSeparatorBox)
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxs.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxs.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxs.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    gcCharMask1.CharBoxes.Add(DirectCast(aInputBoxs.Clone(), GrapeCity.Win.Spread.InputMan.CellType.CharBoxInfo))
    ' GcCharMask型セルをセルに設定します。           
    FpSpread1.Sheets(0).Cells(1, 1).CellType = gcCharMask1
End Sub

 

 


Copyright © 2004 GrapeCity inc.