Spread WPF Documentation
PrintToDocument() Method
Example 


GrapeCity.Windows.SpreadSheet.UI Namespace > GcSpreadSheet Class > PrintToDocument Method : PrintToDocument() Method
Syntax
'Declaration
 
Public Overloads Function PrintToDocument() As System.Windows.Documents.IDocumentPaginatorSource
'Usage
 
Dim instance As GcSpreadSheet
Dim value As System.Windows.Documents.IDocumentPaginatorSource
 
value = instance.PrintToDocument()
public System.Windows.Documents.IDocumentPaginatorSource PrintToDocument()
Example
This example uses the PrintToDocument method.
internal class PrintDocumentViewer : DocumentViewer
        {
            public PrintDocumentViewer(GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet spread, int sheetIndex)
            {
                this.Spread = spread;
                this.SheetIndex = sheetIndex;
                this.Document = spread.PrintToDocument();
            }

            protected override void OnPrintCommand()
            {
                if (this.Spread != null)
                {
                    if (this.SheetIndex != -1)
                    {
                        this.Spread.Print(this.SheetIndex);
                    }
                    else
                    {
                        this.Spread.Print();
                    }
                }

            }
            private GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet Spread { get; set; }
            private int SheetIndex { get; set; }
        }           

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            Window window = new Window();
            PrintDocumentViewer viewer = new PrintDocumentViewer(GcSpreadSheet1, -1);
            window.Content = viewer;
            window.ShowDialog();
        }
Friend Class PrintDocumentViewer
        Inherits DocumentViewer
        Public Sub New(spread As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet, sheetIndex As Integer)
            Me.Spread = spread
            Me.SheetIndex = sheetIndex
            Me.Document = spread.PrintToDocument()
        End Sub

        Protected Overrides Sub OnPrintCommand()
            If Me.Spread IsNot Nothing Then
                If Me.SheetIndex <> -1 Then
                    Me.Spread.Print(Me.SheetIndex)
                Else
                    Me.Spread.Print()
                End If
            End If
        End Sub

        Private Property Spread() As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
            Get
                Return m_Spread
            End Get
            Set(value As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet)
                m_Spread = value
            End Set
        End Property
        Private m_Spread As GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
        Private Property SheetIndex() As Integer
            Get
                Return m_SheetIndex
            End Get
            Set(value As Integer)
                m_SheetIndex = Value
            End Set
        End Property
        Private m_SheetIndex As Integer
    End Class

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Dim window As New Window()
        Dim viewer As New PrintDocumentViewer(GcSpreadSheet1, -1)
        window.Content = viewer
        window.ShowDialog()
    End Sub
See Also

Reference

GcSpreadSheet Class
GcSpreadSheet Members
Overload List