Reports for WinForms
ページへの列の追加

ページに列を追加するには、Add メソッドを使用します。

  1. ツールボックスからプロジェクトに C1PrintPreviewControl およびC1PrintDocumentコントロールを追加します。
  2. C1PrintPreviewControl1 をクリックして選択し、プロパティウィンドウでその Document プロパティを C1PrintDocument1 に設定します。
  3. Form_Load イベントに次のコードを追加します。

    Visual Basic コードの書き方

    Visual Basic
    コードのコピー
    ' ドキュメントを作成します。    
    MakeDoc();
     
    ' ドキュメントを生成します.    
    this.c1PrintDocument1.Generate();
    

    C# コードの書き方

    C#
    コードのコピー
    // ドキュメントを作成します。    
    MakeDoc()
    
    // ドキュメントを生成します    
    Me.C1PrintDocument1.Generate()
    
  4. MakeDoc サブルーチンを追加します。このサブルーチンは、Add メソッドを使用して、ドキュメントのすべてのページに列を追加します。

    Visual Basic コードの書き方

    Visual Basic
    コードのコピー
    Private Sub MakeDoc()
    
       ' ページレイアウトを作成します。    
       Dim pl As New C1.C1Preview.PageLayout
    
       ' 列を追加します。    
       pl.Columns.Add()    
       pl.Columns.Add()    
       pl.PageSettings = New C1.C1Preview.C1PageSettings()    
       Me.C1PrintDocument1.PageLayouts.Default = pl
    
       ' RenderText1 を作成します。    
       Dim rt1 As New C1.C1Preview.RenderText    
       rt1.Text = "This is the house that Jack built. This is the carrot, that lay in the house that Jack built. This is the rat, that ate the carrot, that lay in the house that Jack built. This is the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built."
    
       ' 段区切りを挿入します。    
       rt1.BreakAfter = C1.C1Preview.BreakEnum.Column
    
       '  RenderText2 を作成します。    
       Dim rt2 As New C1.C1Preview.RenderText    
       rt2.Text = "This is the dog that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack  built. This is the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack  built."
    
       ' 段区切りを挿入します。    
       rt2.BreakAfter = C1.C1Preview.BreakEnum.Column
    
       '  RenderText3 を作成します。    
       Dim rt3 As New C1.C1Preview.RenderText    
       rt3.Text = "This is the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the cock that crowed in the morn, that waked the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the farmer sowing the corn, that kept the cock that crowed in the morn, that waked the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built."
    
       ' RenderText をドキュメントに追加します。    
       Me.C1PrintDocument1.Body.Children.Add(rt1)    
       Me.C1PrintDocument1.Body.Children.Add(rt2)    
       Me.C1PrintDocument1.Body.Children.Add(rt3)    
    End Sub
    

    C# コードの書き方

    C#
    コードのコピー
    public void MakeDoc()    
    {
    
       //ページレイアウトを作成します。    
       C1.C1Preview.PageLayout pl = new C1.C1Preview.PageLayout();
    
       //列を追加します。    
       pl.Columns.Add();    
       pl.Columns.Add();     
       pl.PageSettings = new C1.C1Preview.C1PageSettings();    
       this.c1PrintDocument1.PageLayouts.Default = pl;
    
       // RenderText1 を作成します。    
       C1.C1Preview.RenderText rt1 = new C1.C1Preview.RenderText();    
       rt1.Text = "This is the house that Jack built. This is the carrot, that lay in the house that Jack built. This is the rat, that ate the carrot, that lay in the house that Jack built. This is the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built."; 
    
       // 段区切りを挿入します。    
       rt1.BreakAfter = C1.C1Preview.BreakEnum.Column;
    
       //  RenderText2 を作成します。    
       C1.C1Preview.RenderText rt2 = new C1.C1Preview.RenderText();    
       rt2.Text = "This is the dog that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built.";
    
       // 段区切りを挿入します。    
       rt2.BreakAfter = C1.C1Preview.BreakEnum.Column;
    
       // RenderText3 を作成します。    
       C1.C1Preview.RenderText rt3 = new C1.C1Preview.RenderText();    
       rt3.Text = "This is the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the cock that crowed in the morn, that waked the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built. This is the farmer sowing the corn, that kept the cock that crowed in the morn, that waked the priest all shaven and shorn, that married the man all tattered and torn, that kissed the maiden all forlorn, that milked the cow with the crumbled horn, that tossed the dog, that worried the cat, that chased the rat, that ate the carrot, that lay in the house that Jack built.";
    
       //RenderText をドキュメントに追加します。    
       this.c1PrintDocument1.Body.Children.Add(rt1);    
       this.c1PrintDocument1.Body.Children.Add(rt2);    
       this.c1PrintDocument1.Body.Children.Add(rt3);    
    }
    

このトピックの作業結果

ドキュメントの各ページの2列にテキストが表示されます。