GrapeCity SPREAD for Windows Forms 11.0J サンプルコード集
フィールドのスタイルを変更する

GcMask型セルの書式を構成する各フィールドに対して、それぞれスタイルを設定できます。フィールドにスタイルを設定するには、各フィールドを表すフィールドオブジェクトのプロパティを使用します。

【実行例】

private void Form1_Load(object sender, EventArgs e)
{
    GrapeCity.Win.Spread.InputMan.CellType.GcMaskCellType gcMask1 = new GrapeCity.Win.Spread.InputMan.CellType.GcMaskCellType() { PaintByControl = true };
    // 列挙型フィールドの設定
    GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskEnumerationFieldInfo maskEnumerationField1 = 
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskEnumerationFieldInfo(new string[] { "【直通】", "【携帯】", "【呼出】" })
        {
            AutoDropDown=true,
            DropDownEnabled=true,
            ForeColor=Color.OrangeRed
        };
    // パターンフィールドの設定            
    GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo maskPatternField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo() { MaxLength = 3, MinLength = 3, Pattern = "\\D", PromptChar = '*' };
    // リテラル文字フィールドの設定
    GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskLiteralFieldInfo maskLiteralField1 =
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskLiteralFieldInfo() { ForeColor = Color.OrangeRed, Text = "-" };
    // パターンフィールドの設定
    GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo maskPatternField2 = 
        new GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo() { MaxLength = 4, MinLength = 4, Pattern = "\\D", PromptChar = '*' };                   
    // 各フィールドをGcMask型セルに追加
    gcMask1.Fields.Add(maskEnumerationField1);
    gcMask1.Fields.Add(maskPatternField1);
    gcMask1.Fields.Add(maskLiteralField1);
    gcMask1.Fields.Add(maskPatternField2);
    gcMask1.Fields.Add(maskLiteralField1);
    gcMask1.Fields.Add(maskPatternField2);
    // GcMask型セルをセルに設定
    fpSpread1.Sheets[0].Cells[1, 1].CellType = gcMask1;
}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim gcMask1 As New GrapeCity.Win.Spread.InputMan.CellType.GcMaskCellType() With {
        .PaintByControl = True
    }
    ' 列挙型フィールドの設定
    Dim maskEnumerationField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskEnumerationFieldInfo(New String() {"【直通】", "【携帯】", "【呼出】"}) With {
        .AutoDropDown = True,
        .DropDownEnabled = True,
        .ForeColor = Color.OrangeRed
    }
    ' パターンフィールドの設定            
    Dim maskPatternField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo() With {
        .MaxLength = 3,
        .MinLength = 3,
        .Pattern = "\D",
        .PromptChar = "*"c
    }
    ' リテラル文字フィールドの設定
    Dim maskLiteralField1 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskLiteralFieldInfo() With {
        .ForeColor = Color.OrangeRed,
        .Text = "-"
    }
    ' パターンフィールドの設定
    Dim maskPatternField2 As New GrapeCity.Win.Spread.InputMan.CellType.Fields.MaskPatternFieldInfo() With {
        .MaxLength = 4,
        .MinLength = 4,
        .Pattern = "\D",
        .PromptChar = "*"c
    }
    ' 各フィールドをGcMask型セルに追加
    gcMask1.Fields.Add(maskEnumerationField1)
    gcMask1.Fields.Add(maskPatternField1)
    gcMask1.Fields.Add(maskLiteralField1)
    gcMask1.Fields.Add(maskPatternField2)
    gcMask1.Fields.Add(maskLiteralField1)
    gcMask1.Fields.Add(maskPatternField2)
    ' GcMask型セルをセルに設定
    FpSpread1.Sheets(0).Cells(1, 1).CellType = gcMask1
End Sub

 

 


© 2004-2018, GrapeCity inc. All rights reserved.