PowerTools MultiRow for Windows Forms 8.0J
PrintSettings プロパティ
使用例 

印刷時の設定を取得します。
構文
Public ReadOnly Property PrintSettings As PrintSettings
public PrintSettings PrintSettings {get;}

プロパティ値

印刷時の設定を表すPrintSettings値。
解説

GcMultiRowをGraphicsに印刷できます。印刷設定をカスタマイズすることも可能です。異なるページスタイルを使用する場合は、PrintSettings.PagingModeを異なる値に設定します。また、PrintSettings.PrintRangeプロパティを使用して、印刷する行を選択することもできます。MultiRowPrintRange.SomeRowsを使用すると、PrintSettings.FromRowからPrintSettings.ToRowまでの行が選択されます。行間に余白を設ける場合は、PrintSettings.SectionMarginプロパティを設定します。PrintSettings.PagingModePagingMode.MultiColumnsの場合は、PrintSettings.ColumnMarginを使用して列間の余白を指定できます。

各ページにColumnHeaderSectionColumnFooterSectionをどのように印刷するかは、PrintSettings.PrintHeaderプロパティまたはPrintSettings.PrintFooterプロパティによって指定します。

Templateの幅がページの幅より小さいまたは大きい場合は、PrintSettings.AutoFitWidthを使用して、テンプレートの幅をページの幅に自動的に合わせるかどうかを制御できます。GcMultiRowを一定のズーム倍率でページに印刷する場合は、PrintSettings.ZoomFactorプロパティを設定します。

この設定は、PrintPrint(Boolean)PrintPreviewPrintPreview(Int32)、およびDocumentで使用されます。

使用例
次のサンプルコードは、GcMultiRowの印刷方法を示します。GcMultiRowを印刷する前に、必要なPrintSettingsを設定します。その後、PrintPreviewを実行して印刷結果をプレビューするか、Printを実行してプリンタに直接印刷します。このプロパティを通じて、各種PrintSettings.PrintStylePrintSettings.PagingModeを設定し、必要に応じて印刷設定を実行できます。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Globalization;

namespace GrapeCity.Win.MultiRow.SampleCode
{
    class PrintDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private FlowLayoutPanel panel = new FlowLayoutPanel();
        private bool flag = false;

        public PrintDemo()
        {
            this.Text = "Print Demo";
            this.Size = new Size(700, 400);

            // Initial flow layout panel and add to form.
            this.panel.Dock = DockStyle.Left;
            this.panel.Size = new Size(200, 200);
            this.panel.FlowDirection = FlowDirection.TopDown;
            this.panel.WrapContents = false;
            this.panel.Padding = new Padding(5);
            this.panel.AutoSize = true;
            this.Controls.Add(panel);

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Left;
            this.gcMultiRow1.Width = 400;
            this.Controls.Add(this.gcMultiRow1);

            label.Height = 50;
            label.Dock = DockStyle.Bottom;
            label.BackColor = SystemColors.Info;
            label.Text = "Please Click one button to view the corresponding print preview effect.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            InitButton();

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = CreateTemplate(3, 21);
            gcMultiRow1.RowCount = 5;
        }

        #region Button Event Handlers
        void setRichAndFlowButton_Click(object sender, EventArgs e)
        {
            Template template1 = CreateTemplate(3, 21);
            AddPrintInfoCellColumnFooterSection(template1, 21);
            this.gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 50;

            //The all UI elements will be printed, like UpDown button.
            gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich;
            //The all Rows will be printed from first page to last page one by one.
            gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow;
            //The GcMultiRow will be aligned by MiddleLeft.
            gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleLeft;
            //Between every two Rows, there will exist 15 pixels space.
            gcMultiRow1.PrintSettings.SectionMargin = 15;
            //Only the Row from 2th to 8th are printed
            gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.SomeRows;
            gcMultiRow1.PrintSettings.FromRow = 2;
            gcMultiRow1.PrintSettings.ToRow = 8;

            if (flag)
            {
                //The Template's width is less than page's width, set AutoFitWidth to true, the Template will be zoomed out to fit the page's width.
                gcMultiRow1.PrintSettings.AutoFitWidth = true;
                flag = false;
            }
            else
            {
                gcMultiRow1.PrintSettings.AutoFitWidth = false;
                flag = true;
            }
            gcMultiRow1.PrintSettings.ZoomFactor = 1f;
            try
            {
                gcMultiRow1.PrintPreview();
                //If you have a printer, you can execute the following code directly instead code above.
                //gcMultiRow1.Print(true);
            }
            catch (Exception ex)
            {
                // Can't find printer driver.
                MessageBox.Show(ex.Message);
            }
            label.Text = "In Rich style, all elements will be printed, like UpDown button; Between two rows, 15 pixels space existed; Only  the 2th to 8th row are printed one by one from page's Top to Bottom; The GcMultiRow will be aligned by MiddleLeft; (Click the button again to view the AutoFitWidth property's effect)";
        }

        void setRichAndSingleRowButton_Click(object sender, EventArgs e)
        {
            Template template1 = CreateTemplate(10, 100);
            AddPrintInfoCellColumnFooterSection(template1, 100);
            this.gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 5;

            //All elements will be printed.
            gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich;
            //Only one Row will be printed to one page. You can print ColumnHeader to each page through setting PrintHeader property to AllPages.
            gcMultiRow1.PrintSettings.PagingMode = PagingMode.SingleRow;
            //The GcMultiRow will be aligned by MiddleCenter.
            gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter;
            //All Rows will be printed.
            gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows;
            //In each page, besides one Row, the ColumnHeader will be printed in the page's head.
            gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages;
            //In each page, besides one Row, the ColumnFooter will be printed in the page's tail.
            gcMultiRow1.PrintSettings.PrintFooter = PrintFooter.AllPages;
            if (flag)
            {
                //If Template's width is greater than page's width, the excess part will be printed to new page.
                gcMultiRow1.PrintSettings.HorizontalPageBreak = true;
                flag = false;
            }
            else
            {
                //If Template's width is greater than page's width, the excess part will be clipped.
                gcMultiRow1.PrintSettings.HorizontalPageBreak = false;
                flag = true;
            }
            gcMultiRow1.PrintSettings.AutoFitWidth = false;
            gcMultiRow1.PrintSettings.ZoomFactor = 1f;
            try
            {
                gcMultiRow1.PrintPreview();
                //If you have a printer, you can execute the following code directly instead code above.
                //gcMultiRow1.Print(true);
            }
            catch (Exception ex)
            {
                // Can't find printer driver.
                MessageBox.Show(ex.Message);
            }
            label.Text = "The each Row will be printed in each page with the ColumnHeader; The GcMultiRow will be aligned by MiddleCenter; Because the Template's width is greater than page's width, The HorizontalPageBreak will control whether the excess part will be printed to new page.(Click the button again to chang the HorizontalPageBreak's effect)";
        }

        void setCompactAndZoomFactorButton_Click(object sender, EventArgs e)
        {
            Template template1 = CreateTemplate(2, 21);
            AddPrintInfoCellColumnFooterSection(template1, 21);
            this.gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 20;

            //Some UI elements will not be printed, like UpDown button.
            gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Compact;
            gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow;
            gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter;
            gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows;
            if (flag)
            {
                //The Template will be printed to page with the zoom ratio 3.
                gcMultiRow1.PrintSettings.ZoomFactor = 3f;
                flag = false;
            }
            else
            {
                gcMultiRow1.PrintSettings.ZoomFactor = 1f;
                flag = true;
            }
            gcMultiRow1.PrintSettings.AutoFitWidth = false;
            try
            {
                gcMultiRow1.PrintPreview();
                //If you have a printer, you can execute the following code directly instead code above.
                //gcMultiRow1.Print(true);
            }
            catch (Exception ex)
            {
                // Can't find printer driver.
                MessageBox.Show(ex.Message);
            }
            label.Text = "The Compact style will not print some UI elements, like UpDown button; Click the button again to view how the ZoomFactor property takes effect.";
        }

        void setContentAndMultiColumnButton_Click(object sender, EventArgs e)
        {
            Template template1 = CreateTemplate(1, 21);
            AddPrintInfoCellColumnFooterSection(template1, 21);
            this.gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 81;

            //Only the content(Text,Image) is printed, the backgound, border will not be printed.
            gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Content;
            gcMultiRow1.PrintSettings.AutoFitWidth = false;
            //Only one Row will be printed to one page. You can print ColumnHeader to each page through setting PrintHeader property to AllPages.
            gcMultiRow1.PrintSettings.PagingMode = PagingMode.MultiColumns;
            //The all Columns in each page will be aligned by MiddleCenter.
            gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter;
            //All Rows will be printed.
            gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows;
            //In MultiColumns mode, on each Column's head, the ColumnHeader is filled. If you can set this to FirstPage, only first Column exists one ColumnHeader.
            gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages;
            //Between each Column in page, there will exist 15 pixels space.
            gcMultiRow1.PrintSettings.ColumnMargin = 15;

            if (flag)
            {
                gcMultiRow1.PrintSettings.MultiColumnsPrintOrder = PrintOrder.OverThenDown;
                flag = false;
            }
            else
            {
                gcMultiRow1.PrintSettings.MultiColumnsPrintOrder = PrintOrder.DownThenOver;
                flag = true;
            }
            gcMultiRow1.PrintSettings.ZoomFactor = 1f;
            try
            {
                gcMultiRow1.PrintPreview();
                //If you have a printer, you can execute the following code directly instead code above.
                //gcMultiRow1.Print(true);
            }
            catch (Exception ex)
            {
                // Can't find printer driver.
                MessageBox.Show(ex.Message);
            }
            label.Text = "In Content style, only the Text and Image are printed; In MultiColumns mode, the MultiColumnsPrintOrder can control all Rows printing order; The ColumnMargin property will set 15 pixels space between each column;(Click this button again, the MultiColumnsPrintOrder will change to another effect.)";
        }

        void AddPrintInfoCellColumnFooterSection(Template template, int height)
        {
            ColumnFooterSection columnFooterSection1 = new ColumnFooterSection();
            columnFooterSection1.Height = height;

            PrintInfoCell printInfoCell1 = new PrintInfoCell();
            printInfoCell1.Size = new Size(500, height);
            printInfoCell1.Location = new Point(template.Width - 500, 0);
            printInfoCell1.Style.Border = Border.Empty;
            printInfoCell1.Style.TextAlign = MultiRowContentAlignment.MiddleRight;

            CultureInfo provider = new CultureInfo("ja-JP",true);
            provider.DateTimeFormat.Calendar = new JapaneseCalendar();
            printInfoCell1.Style.FormatProvider = provider;
            //Indicate the page number and DateTime.
            printInfoCell1.FormatString = "{PageNumber:}/{PageCount:} {DateTime:yyyy年MM月dd日}";
            //You can add other information when printing, such as UserName, CompanyName and so on.
            //printInfoCell1.FormatString = String.Format("{{DateTime:yyyy年MM月dd日}} {0} {1} ",new object[] { Environment.UserName, Application.CompanyName });

            columnFooterSection1.Cells.Add(printInfoCell1);
            template.ColumnFooters.Add(columnFooterSection1);
        }
        #endregion

        #region Initialize Buttons

        private void InitButton()
        {
            AddButton(setRichAndFlowButton, "Click to set Rich style and Flow mode", new EventHandler(setRichAndFlowButton_Click));
            AddButton(setRichAndSingleRowButton, "Click to set Rich style and SingleRow mode", new EventHandler(setRichAndSingleRowButton_Click));
            AddButton(setCompactAndZoomFactorButton, "Click to set Compact style and ZoomFactor", new EventHandler(setCompactAndZoomFactorButton_Click));
            AddButton(setContentAndMultiColumnButton, "Click to set Content style and MultiColumns mode", new EventHandler(setContentAndMultiColumnButton_Click));
        }

        private void AddButton(Button button, string text, EventHandler eventHandler)
        {
            this.panel.Controls.Add(button);
            button.Text = text;
            button.AutoSize = true;
            button.Click += eventHandler;
        }

        Button setRichAndFlowButton = new Button();
        Button setRichAndSingleRowButton = new Button();
        Button setCompactAndZoomFactorButton = new Button();
        Button setContentAndMultiColumnButton = new Button();
        Label label = new Label();
        #endregion

        #region Create one single Cell Template
        private Template CreateTemplate(int columnCount, int rowHeight)
        {
            NumericUpDownCell number1 = new NumericUpDownCell();
            number1.Size = new Size(80, rowHeight);
            Cell[] cells = new Cell[columnCount];
            for (int i = 0; i < cells.Length; i++)
            {
                cells[i] = number1.Clone() as Cell;
            }

            Template template1 = Template.CreateGridTemplate(cells, Int32.MaxValue,
                AutoGenerateGridTemplateStyles.RowHeaderAutoNumber | AutoGenerateGridTemplateStyles.ColumnHeader, 50);
            for (int i = 0; i < template1.Row.Cells.Count - 1; i++)
            {
                template1.Row.Cells[i].Value = i + 1;
            }
            template1.AlternatingRowsDefaultCellStyle.BackColor = Color.MediumSeaGreen;
            template1.RowsDefaultCellStyle.BackColor = Color.MediumVioletRed;

            return template1;
        }
        #endregion

        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new PrintDemo());
        }
    }
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Globalization
Imports GrapeCity.Win.MultiRow

Class PrintDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()
    Private flag As Boolean = False

    Public Sub New()
        Me.Text = "Print Demo"
        Me.Size = New Size(700, 400)

        ' Initial flow layout panel and add to form.
        Me.panel.Dock = DockStyle.Left
        Me.panel.Size = New Size(200, 200)
        Me.panel.FlowDirection = FlowDirection.TopDown
        Me.panel.WrapContents = False
        Me.panel.Padding = New Padding(5)
        Me.panel.AutoSize = True
        Me.Controls.Add(panel)

        ' Add MultiRow to form
        Me.gcMultiRow1.Dock = DockStyle.Left
        Me.gcMultiRow1.Width = 400
        Me.Controls.Add(Me.gcMultiRow1)

        label.Height = 50
        label.Dock = DockStyle.Bottom
        label.BackColor = SystemColors.Info
        label.Text = "Please Click one button to view the corresponding print preview effect."
        Me.Controls.Add(label)

        InitButton()

        Me.StartPosition = FormStartPosition.CenterScreen
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = CreateTemplate(3, 21)
        gcMultiRow1.RowCount = 5
    End Sub

#Region "Button Event Handlers"
    Private Sub setRichAndFlowButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRichAndFlowButton.Click
        Dim template1 As Template = CreateTemplate(3, 21)
        AddPrintInfoCellColumnFooterSection(template1, 21)
        Me.gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 50

        'The all UI elements will be printed, like UpDown button.
        gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich
        'The all Rows will be printed from first page to last page one by one.
        gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow
        'The GcMultiRow will be aligned by MiddleLeft.
        gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleLeft
        'Between every two Rows, there will exist 15 pixels space.
        gcMultiRow1.PrintSettings.SectionMargin = 15
        'Only the Row from 2th to 8th are printed
        gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.SomeRows
        gcMultiRow1.PrintSettings.FromRow = 2
        gcMultiRow1.PrintSettings.ToRow = 8

        If flag Then
            'The Template's width is less than page's width, set AutoFitWidth to true, the Template will be zoomed out to fit the page's width.
            gcMultiRow1.PrintSettings.AutoFitWidth = True
            flag = False
        Else
            gcMultiRow1.PrintSettings.AutoFitWidth = False
            flag = True
        End If
        gcMultiRow1.PrintSettings.ZoomFactor = 1.0F
        Try
            'If you have a printer, you can execute the following code directly instead code above.
            'gcMultiRow1.Print(true);
            gcMultiRow1.PrintPreview()
        Catch ex As Exception
            ' Can't find printer driver.
            MessageBox.Show(ex.Message)
        End Try
        label.Text = "In Rich style, all elements will be printed, like UpDown button; Between two rows, 15 pixels space existed; Only  the 2th to 8th row are printed one by one from page's Top to Bottom; The GcMultiRow will be aligned by MiddleLeft; (Click the button again to view the AutoFitWidth property's effect)"
    End Sub

    Private Sub setRichAndSingleRowButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRichAndSingleRowButton.Click
        Dim template1 As Template = CreateTemplate(10, 100)
        AddPrintInfoCellColumnFooterSection(template1, 100)
        Me.gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 5

        'All elements will be printed.
        gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Rich
        'Only one Row will be printed to one page. You can print ColumnHeader to each page through setting PrintHeader property to AllPages.
        gcMultiRow1.PrintSettings.PagingMode = PagingMode.SingleRow
        'The GcMultiRow will be aligned by MiddleCenter.
        gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter
        'All Rows will be printed.
        gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows
        'In each page, besides one Row, the ColumnHeader will be printed in the page's head.
        gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages
        'In each page, besides one Row, the ColumnFooter will be printed in the page's tail.
        gcMultiRow1.PrintSettings.PrintFooter = PrintFooter.AllPages

        If flag Then
            'If Template's width is greater than page's width, the excess part will be printed to new page.
            gcMultiRow1.PrintSettings.HorizontalPageBreak = True
            flag = False
        Else
            'If Template's width is greater than page's width, the excess part will be clipped.
            gcMultiRow1.PrintSettings.HorizontalPageBreak = False
            flag = True
        End If
        gcMultiRow1.PrintSettings.AutoFitWidth = False
        gcMultiRow1.PrintSettings.ZoomFactor = 1.0F
        Try
            'If you have a printer, you can execute the following code directly instead code above.
            'gcMultiRow1.Print(true);
            gcMultiRow1.PrintPreview()
        Catch ex As Exception
            ' Can't find printer driver.
            MessageBox.Show(ex.Message)
        End Try
        label.Text = "The each Row will be printed in each page with the ColumnHeader; The GcMultiRow will be aligned by MiddleCenter; Because the Template's width is greater than page's width, The HorizontalPageBreak will control whether the excess part will be printed to new page.(Click the button again to chang the HorizontalPageBreak's effect)"
    End Sub

    Private Sub setCompactAndZoomFactorButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setCompactAndZoomFactorButton.Click
        Dim template1 As Template = CreateTemplate(2, 21)
        AddPrintInfoCellColumnFooterSection(template1, 21)
        Me.gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 20

        'Some UI elements will not be printed, like UpDown button.
        gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Compact
        gcMultiRow1.PrintSettings.PagingMode = PagingMode.Flow
        gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter
        gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows
        If flag Then
            'The Template will be printed to page with the zoom ratio 3.
            gcMultiRow1.PrintSettings.ZoomFactor = 3.0F
            flag = False
        Else
            gcMultiRow1.PrintSettings.ZoomFactor = 1.0F
            flag = True
        End If
        gcMultiRow1.PrintSettings.AutoFitWidth = False
        Try
            'If you have a printer, you can execute the following code directly instead code above.
            'gcMultiRow1.Print(true);
            gcMultiRow1.PrintPreview()
        Catch ex As Exception
            ' Can't find printer driver.
            MessageBox.Show(ex.Message)
        End Try
        label.Text = "The Compact style will not print some UI elements, like UpDown button; Click the button again to view how the ZoomFactor property takes effect."
    End Sub

    Private Sub setContentAndMultiColumnButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setContentAndMultiColumnButton.Click
        Dim template1 As Template = CreateTemplate(1, 21)
        AddPrintInfoCellColumnFooterSection(template1, 21)
        Me.gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 81

        'Only the content(Text,Image) is printed, the backgound, border will not be printed.
        gcMultiRow1.PrintSettings.PrintStyle = PrintStyle.Content
        gcMultiRow1.PrintSettings.AutoFitWidth = False
        'Only one Row will be printed to one page. You can print ColumnHeader to each page through setting PrintHeader property to AllPages.
        gcMultiRow1.PrintSettings.PagingMode = PagingMode.MultiColumns
        'The all Columns in each page will be aligned by MiddleCenter.
        gcMultiRow1.PrintSettings.Alignment = MultiRowContentAlignment.MiddleCenter
        'All Rows will be printed.
        gcMultiRow1.PrintSettings.PrintRange = MultiRowPrintRange.AllRows
        'In MultiColumns mode, on each Column's head, the ColumnHeader is filled. If you can set this to FirstPage, only first Column exists one ColumnHeader.
        gcMultiRow1.PrintSettings.PrintHeader = PrintHeader.AllPages
        'Between each Column in page, there will exist 15 pixels space.
        gcMultiRow1.PrintSettings.ColumnMargin = 15

        If flag Then
            gcMultiRow1.PrintSettings.MultiColumnsPrintOrder = PrintOrder.OverThenDown
            flag = False
        Else
            gcMultiRow1.PrintSettings.MultiColumnsPrintOrder = PrintOrder.DownThenOver
            flag = True
        End If
        gcMultiRow1.PrintSettings.ZoomFactor = 1.0F
        Try
            'If you have a printer, you can execute the following code directly instead code above.
            'gcMultiRow1.Print(true);
            gcMultiRow1.PrintPreview()
        Catch ex As Exception
            ' Can't find printer driver.
            MessageBox.Show(ex.Message)
        End Try
        label.Text = "In Content style, only the Text and Image are printed; In MultiColumns mode, the MultiColumnsPrintOrder can control all Rows printing order; The ColumnMargin property will set 15 pixels space between each column;(Click this button again, the MultiColumnsPrintOrder will change to another effect.)"
    End Sub

    Private Sub AddPrintInfoCellColumnFooterSection(ByVal template As Template, ByVal height As Integer)
        Dim columnFooterSection1 As New ColumnFooterSection()
        columnFooterSection1.Height = height

        Dim printInfoCell1 As New PrintInfoCell()
        printInfoCell1.Size = New Size(500, height)
        printInfoCell1.Location = New Point(template.Width - 500, 0)
        printInfoCell1.Style.Border = Border.Empty
        printInfoCell1.Style.TextAlign = MultiRowContentAlignment.MiddleRight

        Dim provider As New CultureInfo("ja-JP", True)
        provider.DateTimeFormat.Calendar = New JapaneseCalendar()
        printInfoCell1.Style.FormatProvider = provider
        'Indicate the page number and DateTime.
        printInfoCell1.FormatString = "{PageNumber:}/{PageCount:} {DateTime:yyyy年MM月dd日}"
        'You can add other information when printing, such as UserName, CompanyName and so on.
        'printInfoCell1.FormatString = String.Format("{{DateTime:yyyy年MM月dd日}} {0} {1} ",new object[] { Environment.UserName, Application.CompanyName });

        columnFooterSection1.Cells.Add(printInfoCell1)
        template.ColumnFooters.Add(columnFooterSection1)
    End Sub
#End Region

#Region "Initialize Buttons"

    Private Sub InitButton()
        AddButton(setRichAndFlowButton, "Click to set Rich style and Flow mode")
        AddButton(setRichAndSingleRowButton, "Click to set Rich style and SingleRow mode")
        AddButton(setCompactAndZoomFactorButton, "Click to set Compact style and ZoomFactor")
        AddButton(setContentAndMultiColumnButton, "Click to set Content style and MultiColumns mode")
    End Sub

    Private Sub AddButton(ByVal button As Button, ByVal text As String)
        Me.panel.Controls.Add(button)
        button.Text = text
        button.AutoSize = True
    End Sub

    Friend WithEvents setRichAndFlowButton As New Button()
    Friend WithEvents setRichAndSingleRowButton As New Button()
    Friend WithEvents setCompactAndZoomFactorButton As New Button()
    Friend WithEvents setContentAndMultiColumnButton As New Button()
    Private label As New Label()
#End Region

#Region "Create one single Cell Template"
    Private Function CreateTemplate(ByVal columnCount As Integer, ByVal rowHeight As Integer) As Template
        Dim number1 As New NumericUpDownCell()
        number1.Size = New Size(80, rowHeight)
        Dim cells As Cell() = New Cell(columnCount - 1) {}

        For i As Integer = 0 To cells.Length - 1
            cells(i) = TryCast(number1.Clone(), Cell)
        Next

        Dim template1 As Template = Template.CreateGridTemplate(cells)

        For i As Integer = 0 To template1.Row.Cells.Count - 2
            template1.Row.Cells(i).Value = i + 1
        Next

        template1.AlternatingRowsDefaultCellStyle.BackColor = Color.MediumSeaGreen
        template1.RowsDefaultCellStyle.BackColor = Color.MediumVioletRed
        Return template1
    End Function
#End Region

    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New PrintDemo())
    End Sub
End Class
参照

GcMultiRow クラス
GcMultiRow メンバ
Print メソッド
PrintPreview メソッド
PageSetup メソッド
Document プロパティ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.