PowerTools MultiRow for Windows Forms 8.0J
Save(Stream) メソッド
使用例 

ターゲットXMLファイルストリーム。
現在のNamedCellStyleDictionaryをXMLファイルストリームにシリアル化します。
構文
Public Overloads Sub Save( _
   ByVal stream As Stream _
) 
public void Save( 
   Stream stream
)

パラメータ

stream
ターゲットXMLファイルストリーム。
例外
例外解説
System.ArgumentNullExceptionstreamがnull 参照 (Visual Basicでは Nothing)です。
解説
作成したスキンのセットをNamedCellStyleDictionaryに格納してファイルに保存しておき、必要な場合にそれをファイルから読み込むことができます。
使用例
次のサンプルコードは、"AlternatingColumnsDefaultCellStyle"と"ColumnsDefaultCellStyle"を実装する方法を示します。フォームが読み込まれるとき、GcMultiRowTemplateを1つ追加します。このTemplateは、アプリケーションが起動された後、奇数番目の列に"ColumnsDefaultCellStyle"を設定し、偶数番目の列に"AlternatingColumnsDefaultCellStyle"を設定します。"AlternatingColumnsDefaultCellStyle"または"ColumnsDefaultCellStyle"を変更する場合は、GcMultiRow.NamedCellStylesの対応する項目を変更するだけで済みます。そうすると、新しいCellStyleが適用されます。さらに、GcMultiRow.NamedCellStylesをファイルに保存した後、必要に応じてそのファイルを読み込むことができます。このサンプルコードは、NamedCellStyleクラスに示されている詳細なコード例の一部を抜粋したものです。
void setFirstNamedCellStyle_Click(object sender, EventArgs e)
{
    CellStyle alternatingColumnsDefaultCellStyle = new CellStyle();
    alternatingColumnsDefaultCellStyle.BackColor = Color.FromArgb(150, 160, 159);
    alternatingColumnsDefaultCellStyle.ForeColor = Color.White;
    alternatingColumnsDefaultCellStyle.NullValue = "Text";
    //Change the "AlternatingColumnsDefaultCellStyle"
    this.gcMultiRow1.NamedCellStyles["AlternatingColumnsDefaultCellStyle"] = alternatingColumnsDefaultCellStyle;

    CellStyle columnsDefaultCellStyle = new CellStyle();
    columnsDefaultCellStyle.BackColor = Color.FromArgb(226, 228, 228);
    columnsDefaultCellStyle.ForeColor = Color.Black;
    columnsDefaultCellStyle.NullValue = "Text";
    //Change the "ColumnsDefaultCellStyle"
    this.gcMultiRow1.NamedCellStyles["ColumnsDefaultCellStyle"] = columnsDefaultCellStyle;

    //You can load one predefined NamedCellStyleDictionary from one file.
    //this.gcMultiRow1.NamedCellStyles.Load(@"C:\temp\NamedCellStyles.xml");
    //You can save the NamedCellStyleDictionary to one file.
    //this.gcMultiRow1.NamedCellStyles.Save(@"C:\temp\NamedCellStyles.xml");
}
Private Sub setFirstNamedCellStyle_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFirstStyle.Click
    Dim alternatingColumnsDefaultCellStyle As New CellStyle()
    alternatingColumnsDefaultCellStyle.BackColor = Color.FromArgb(150, 160, 159)
    alternatingColumnsDefaultCellStyle.ForeColor = Color.White
    alternatingColumnsDefaultCellStyle.NullValue = "Text"
    'Change the "AlternatingColumnsDefaultCellStyle"
    Me.gcMultiRow1.NamedCellStyles("AlternatingColumnsDefaultCellStyle") = alternatingColumnsDefaultCellStyle

    Dim columnsDefaultCellStyle As New CellStyle()
    columnsDefaultCellStyle.BackColor = Color.FromArgb(226, 228, 228)
    columnsDefaultCellStyle.ForeColor = Color.Black
    columnsDefaultCellStyle.NullValue = "Text"
    'Change the "ColumnsDefaultCellStyle"
    Me.gcMultiRow1.NamedCellStyles("ColumnsDefaultCellStyle") = columnsDefaultCellStyle

    'You can load one predefined NamedCellStyleDictionary from one file.
    'this.gcMultiRow1.NamedCellStyles.Load(@"C:\temp\NamedCellStyles.xml");
    'You can save the NamedCellStyleDictionary to one file.
    'this.gcMultiRow1.NamedCellStyles.Save(@"C:\temp\NamedCellStyles.xml");
End Sub
参照

NamedCellStyleDictionary クラス
NamedCellStyleDictionary メンバ
オーバーロード一覧
Save(string)
Load(Stream)

 

 


© 2008-2015 GrapeCity inc. All rights reserved.