?
Solved

When I print my data grid I get a blank piece of paper.

Posted on 2005-03-09
5
Medium Priority
?
265 Views
Last Modified: 2010-04-16
I have the following event code for a print button.  All I get is a blank piece of paper event though there is data in the grid.  What am I doing wrong?   Thanks in advance.

private void button4_Click(object sender, System.EventArgs e)
            {
             
                  System.Drawing.Printing.PrintDocument printDocument1 = new System.Drawing.Printing.PrintDocument();
                  printDocument1.Print();
            }

            private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                  PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics, new Rectangle(new Point(0, 0), this.Size));
                  this.InvokePaint(grdcustomers, myPaintArgs);
            }

0
Comment
Question by:sean-keys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:brian78wa
ID: 13503126
using System.Drawing.Printing


private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
        PaintEventArgs myPaintArgs =  new PaintEventArgs(e.Graphics, new Rectangle(new Point(0, 0), this.Size));
        this.InvokePaint(grdcustomers, myPaintArgs);
}

private void button1_Click(object sender, System.EventArgs e)
{
        printDialog1.Document =  printDocument1;
        printDocument1.Print();
}
0
 
LVL 1

Expert Comment

by:brian78wa
ID: 13507120
you will need to create or drag over a printDialog control.
0
 

Author Comment

by:sean-keys
ID: 13507651
I added the control, but I get this error when I compile.


      printDialog1.Document =  printDocument1;

The name 'printDocument1' does not exist in the class or namespace 'Customer_Manager.main'


0
 

Author Comment

by:sean-keys
ID: 13510858
Any ideas ?  
0
 
LVL 1

Accepted Solution

by:
brian78wa earned 800 total points
ID: 13511903
i tested the code you gave me and modified it to the code I gave you and it worked fine.
Are you sure you dragged a printDialog control to the right form? and do you have a printdocument control anywhere?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question