This is a migrated thread and some comments may be shown as answers.

PrintView without enoght space for all the columns

9 Answers 191 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ShareDocs
Top achievements
Rank 1
ShareDocs asked on 12 Mar 2013, 08:33 AM
Hi, I am trying to do a printview of a grid with 24 columns and they dont fit in the page event if I do it LandScape.
What the printview is doing is just cuting the columns and just showing some of them. (see attach, you will see 11.5 columns)

How can I do to organice the columns in differents pages (like 12 columns in 1 page and other 12 in other page, or how it fit better)

This is my code

 public static void PrintPreview(RadGridView grdView, bool landscape, string header)
        {
            if (!CheckPrintingValidation(grdView)) return;  //this check that the gridView have data

            RadPrintDocument printDoc = new RadPrintDocument();
            printDoc.Landscape = landscape;
            printDoc.RightHeader = header;
            printDoc.HeaderHeight = 100;
            SetPrintStyle(grdView);
            grdView.PrintPreview(printDoc);
        }

9 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 14 Mar 2013, 02:36 PM
Hello Lior,

Thank you for writing.

Currently, RadGridView cannot be printed on two pages. We have a feature request logged in our Public Issue Tracking System - PITS. You can add your vote/comment to it on the following link - PITS Feature.

To make the columns fit on the page you can set the FitWidthMode of the grid PrintStyle to FitPageWidth. This will size the grid so it would fit on the page. Here is an example:
this.radGridView1.PrintStyle.FitWidthMode = PrintFitWidthMode.FitPageWidth;
I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Ivan Petrov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
ShareDocs
Top achievements
Rank 1
answered on 17 Mar 2013, 10:38 AM

Thanks for your answer but this doesn't work, didn't see any change in the page.
Also it should cut the table and put it in 2 pages, not shrink the columns until fit the page.
24 columns in one page? the user wont be able to see anything

just added my vote in the PITS but please try to give a solution as soon as possible! 

thanks
0
Ivan Petrov
Telerik team
answered on 20 Mar 2013, 02:10 PM
Hi Lior,

Thank you for writing back.

This is what RadGridView printing offers out of the box. Until this feature is implemented you can implement your own printing functionality. For this you will need an object that implements the IPrintable interface which to assign to a RadPrintDocument's AssociatedObject and which would handle the printing. This way you will be able to tailor a custom solution for your scenario that will best address the issues you have.

Should you need assistance, do not hesitate to write back.

Greetings,
Ivan Petrov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
ShareDocs
Top achievements
Rank 1
answered on 24 Mar 2013, 08:09 AM
Ivan, thank for your answer

Can you give me an example please?
I am kind of new in C# world and Telerik.

thanks
0
Ivan Petrov
Telerik team
answered on 27 Mar 2013, 02:49 PM
Hello Lior,

Thank you for your reply.

We do not have a full example of printing the grid on two pages. I can give you the start point from which you can start and implement the printing yourself. However, this is not a trivial task by any means, if you are to succeed in the endeavor you will need deep knowledge of RadGridView. If you feel you can do this you have two options:
1. To implement an IPrintable object which would traverse the grid and print its content.
2. To implement custom GridPrintStyle and a custom GridPrintRenderer, extending the build in functionality.

To get started on version 1 you need and object like this:
public class GridPrinter : IPrintable
{
    private RadGridView grid;
 
    public GridPrinter(RadGridView gridToPrint)
    {
        this.grid = gridToPrint;
    }
 
    int IPrintable.BeginPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
    {
        return 1; //Calculate and return the number of pages you will print
    }
 
    bool IPrintable.EndPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
    {
        return true;
    }
 
    System.Windows.Forms.Form IPrintable.GetSettingsDialog(RadPrintDocument document)
    {
        return null; //This is the dialog form shown when a user clicks on the options button in RadPrintPreviewDialog
    }
 
    bool IPrintable.PrintPage(int pageNumber, RadPrintDocument sender, System.Drawing.Printing.PrintPageEventArgs args)
    {
        //Print the page here
        return false;
    }
}

The second option is to inherit the print renderer used for the normal printing and extend it to print on two pages:
public class MyPrintStyle : GridPrintStyle
{
    public override int GetNumberOfPages(Rectangle drawArea)
    {
        return base.GetNumberOfPages(drawArea) * 2;
    }
 
    protected override BaseGridPrintRenderer InitializePrintRenderer(RadGridView grid)
    {
        if (this.PrintRenderer != null)
        {
            this.PrintRenderer.PrintCellPaint -= renderer_PrintCellPaint;
            this.PrintRenderer.PrintCellFormatting -= renderer_PrintCellFormatting;
        }
 
        MyGridPrintRenderer renderer = new MyGridPrintRenderer();
 
        renderer.PrintCellFormatting += renderer_PrintCellFormatting;
        renderer.PrintCellPaint += renderer_PrintCellPaint;
 
        return renderer;
    }
 
    private void renderer_PrintCellPaint(object sender, PrintCellPaintEventArgs e)
    {
        this.OnPrintCellPaint(sender, e);
    }
 
    private void renderer_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
    {
        this.OnPrintCellFormatting(sender, e);
    }
}
 
public class MyGridPrintRenderer : TableViewDefinitionPrintRenderer
{
    public override void DrawPage(PrintGridTraverser traverser, Rectangle drawArea, Graphics graphics, GridPrintSettings settings, int pageNumber)
    {
        //Using the traverser iterate over the grid and draw through the graphics object.
    }
 
    public override void Reset()
    {
        base.Reset();
        //Reset any helper variables
    }
}

When you have the above implemented you can use it by setting it to the grid PrintStyle property:
this.radGridView1.PrintStyle = new MyPrintStyle();

I hope this will help. Feel free to write back with further inquiries.

All the best,
Ivan Petrov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
ShareDocs
Top achievements
Rank 1
answered on 16 Sep 2013, 10:31 AM
Hi,
Is there any news regarding this topic?

(when printing a grid that is wider then a page)
0
Ivan Petrov
Telerik team
answered on 19 Sep 2013, 08:58 AM
Hi Lior,

Thank you for writing back.

Currently, we are working on a multi-page printing support for RadGridView. We will do our best to include this feature in our next release. You can track the progress of the feature in our PITS by following the link I have posted previously.

I hope this is useful. I would be glad to answer any further questions.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ShareDocs
Top achievements
Rank 1
answered on 30 Dec 2013, 08:52 AM
HI,
Did you make a solution for this?

thanks
0
Ivan Petrov
Telerik team
answered on 30 Dec 2013, 03:53 PM
Hello Lior,

Thank you for your reply.

The functionality is already implemented and was publicly released with our 2013 Q3 release. You can download the new version and test it out. You can read more on how to set it up in the second part of the following help article - GridPrintStyle.

I hope this will help. Do not hesitate to write back with further questions.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
General Discussions
Asked by
ShareDocs
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
ShareDocs
Top achievements
Rank 1
Share this question
or