MESCIUS SPREAD for Windows Forms 17.0J
Type プロパティ (NamedStyleCollectionEventArgs)

発生したイベントの種類を取得します。
構文
'Declaration
 
Public ReadOnly Property Type As NamedStyleCollectionEventType
public NamedStyleCollectionEventType Type {get;}

プロパティ値

イベントの種類を含むNamedStyleCollectionEventType設定
次のサンプルコードは、項目がコレクションに追加されたかどうかを返します。
FarPoint.Win.Spread.NamedStyleCollection nsc;

FarPoint.Win.Spread.NamedStyle[] ns = {new FarPoint.Win.Spread.NamedStyle("Style1"),
new FarPoint.Win.Spread.NamedStyle("Style2"),
new FarPoint.Win.Spread.NamedStyle("Style3")};

private void Form1Load(object sender, System.EventArgs e)
{
    nsc = new FarPoint.Win.Spread.NamedStyleCollection();

    this.nsc.Changed += new FarPoint.Win.Spread.NamedStyleCollectionEventHandler(this.nscChanged); 

    ns[0].Font = new Font("Comic Sans Serif", 12);
    ns[0].Name = "StyleHeaders";
    ns[0].Parent = "HeaderDefault";

    nsc.AddRange(ns);

    fpSpread1.NamedStyles = nsc;
    fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns[0];
}

private void button1Click(object sender, System.EventArgs e)
{
    ns[1].Font = new Font("MS Sans Serif", 12);
    ns[1].Name = "StyleHeaders2";

    nsc.Add(ns[1]);

    fpSpread1.NamedStyles = nsc;
    fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns[1];

}

private void nscChanged(object sender, FarPoint.Win.Spread.NamedStyleCollectionEventArgs e) 
{ 
    try
    {
        MessageBox.Show(e.Type.ItemAdded.ToString());
    }
    catch (Exception ex)
    {
        MessageBox.Show("No Old Style to Report");
    } 
}
Friend WithEvents nsc As FarPoint.Win.Spread.NamedStyleCollection

Dim ns As FarPoint.Win.Spread.NamedStyle() = {New FarPoint.Win.Spread.NamedStyle("Style1"), 
New FarPoint.Win.Spread.NamedStyle("Style2"), 
New FarPoint.Win.Spread.NamedStyle("Style3")}

Private Sub Form1Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    nsc = New FarPoint.Win.Spread.NamedStyleCollection

    Dim eh As FarPoint.Win.Spread.NamedStyleCollectionEventHandler = AddressOf nscChanged
    AddHandler nsc.Changed, eh

    ns(0).Font = New Font("Comic Sans Serif", 12)
    ns(0).Name = "StyleHeaders"
    ns(0).Parent = "HeaderDefault"

    nsc.AddRange(ns)

    FpSpread1.NamedStyles = nsc
    FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns(0)

End Sub

Private Sub nscChanged(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.NamedStyleCollectionEventArgs) Handles nsc.Changed
    Try
        MessageBox.Show(e.Type.ItemAdded.ToString())
    Catch ex As Exception
        MessageBox.Show("No Old Style to Report")
    End Try
End Sub

Private Sub Button1Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ns(1).Font = New Font("MS Sans Serif", FontStyle.Bold)
    ns(1).Name = "StyleHeaders2"

    nsc.Add(ns(1))

    FpSpread1.NamedStyles = nsc
    FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns(1)

End Sub
参照

NamedStyleCollectionEventArgs クラス
NamedStyleCollectionEventArgs メンバ
NamedStyleCollectionEventType 列挙体

開発者ガイド

名前付きスタイル

 

 


© MESCIUS inc. All rights reserved.