Page 1 of 1

Question about Print Preview window

Posted: Fri Aug 25, 2006 3:57 pm
by 9642155
I use the print preview window in my application to display a graph for printing by the following code:

Code: Select all

RectangleF rectfTemp = graphData.Printer.PrintDocument.DefaultPageSettings.PrintableArea;

graphData.Printer.BeginPrint();
graphData.Printer.Print(new Rectangle((int)rectfTemp.X, (int)rectfTemp.Y, (int)rectfTemp.Height, (int)rectfTemp.Width - 100));

graphData.Printer.Preview();
The problem is this: I view the print preview window; I click "Setup..." and change the paper size, and click "OK".

Now the print previewer shows the correct paper size, but the graph is the wrong size (in the control). For example, if I chose a larger paper size (8.5"x14" when before I had 8.5"X11") the graph will not fill the printable area of the page.

The graph will still print correctly though.

I need to use the Printer.Print(rectangle r) overload so I can include some images in the ChartPrint event.

I'm using C# .NET 2005 and TeeChart Pro Version 2.0.2306.26232.

Posted: Fri Aug 25, 2006 4:01 pm
by 9642155
Also, is there any way to get a custom icon on the print preview window?

This isn't critical, but would add continuity to my application.

Posted: Mon Aug 28, 2006 7:59 am
by Marjan
Hi.

As Watermark over chart ? Yes, several ways to do it. You can either paint the image directly on tChart.Chart.Graphics3D in tChart OnAfterDraw event. Alternatively you can also use Annotation tool (with bacground image) or ChartImage tool.

Posted: Mon Aug 28, 2006 6:43 pm
by 9642155
No, I do not wish to print an image on the chart; I want to replace the icon in the upper left hand corner of the Print Preview window (the little picture next to the text "Print Preview" on the title bar).

Posted: Wed Sep 06, 2006 6:00 pm
by 9642155
I am still having the problem with the print preview window that I described in my first post for this thread.

I was just wondering if there is any kind of resolution for this, so that I can still use the same .Print() overload and have the preview window correctly show that page.

Thanks in advance.

Posted: Thu Sep 07, 2006 2:22 pm
by narcis
Hi DCG;

A colleague has encapsulated some of TeeChart’s printing functionality into a class called MyPrinter, which I'll attach as MyPrinter.cs to an e-mail to your forums contact address. You can use this class in the following manner:

Code: Select all

                   private void button2_Click(object sender, System.EventArgs e)
                   {
                            tChart1.Width = 3090;
                            MyPrinter letsPrint = new MyPrinter();
                            //letsPrint.Print(tChart1.Chart, new Rectangle(200,200,200,200));
                            letsPrint.Print(tChart1.Chart, new Point(10,10));
                   }


As you can see from the code in this class, using the public void Print(Chart c, Rectangle r) overload, MyPrinter will print a chart to the specified rectangle, but will clip the rectangle to the size of the paper if the chart is too big. Using the public void Print(Chart c, Point r) overload, MyPrinter will print the top left corner of the chart to the specified point and will calculate the chart size based on the paper size.

Posted: Fri Sep 08, 2006 4:03 pm
by 9642155
Thanks for the help, Narcís!

However, the MyPrinter class that you sent me (apparently) does not have a Print Preview option, so I have decided to go another route with my project.