Articles in this section

How to print the grid in WinForms GridControl?

Print the grid


The GridPrintDocument class implements the printing logic needed to print multi-page Grids. For example, here is a button click event handler that shows you how to use this GridPrintDocument class.

private void Print_Click(object sender, EventArgs e)
{
    if (gridControl1 != null)
    {
        try
        {
            GridPrintDocument gpd = new GridPrintDocument(this.gridControl1);
            PrintDialog pd = new PrintDialog
            {
                Document = gpd,
                AllowSelection = true,
                AllowSomePages = true
            };

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                gpd.Print();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error Occurred: " + ex.Message);
        }
    }
}
Private Sub Print_Click(sender As Object, e As EventArgs) Handles Print.Click
    If gridControl1 IsNot Nothing Then
        Try
            Dim gpd As New GridPrintDocument(Me.gridControl1)
            Dim pd As New PrintDialog With {
                .Document = gpd,
                .AllowSelection = True,
                .AllowSomePages = True
            }

            Dim result As DialogResult = pd.ShowDialog()
            If result = DialogResult.OK Then
                gpd.Print()
            End If
        Catch ex As Exception
            MessageBox.Show("Error Occurred: " & ex.Message)
        End Try
    End If
End Sub

Samples:

C#: Print the grid

VB: Print the grid

 

Reference Link: Printing

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied