473,513 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing using PrintDocument

Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has
about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I tried
using PrintPreviewDialog too but it still only shows just what is visible in
the dialog that houses the dataGrid. I want to get all the datagrid printed.
Maybe wrapping it would be the only way to print all of it...but I don't
know how to grab all the datagrid to the right, the part off screen. Anyone
know how...
Thanks
Nov 15 '05 #1
3 12364
Randy, what are you doing in your Print Events? Could you post that code so
we can see what is going on?

--
Greg Ewing [MVP]
http://www.citidc.com

"Randy" <na*****@hotmail.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I tried
using PrintPreviewDialog too but it still only shows just what is visible in the dialog that houses the dataGrid. I want to get all the datagrid printed. Maybe wrapping it would be the only way to print all of it...but I don't
know how to grab all the datagrid to the right, the part off screen. Anyone know how...
Thanks

Nov 15 '05 #2
Greg,
Sure, it is pretty simple (see below). I have the printDocument1 and the
bPrint button click event and then the printDocument1 printpage event...
Thanks

PrintDocument printDocument1 = new PrintDocument();

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

private void bPrint_Click(object sender, System.EventArgs e)
{
printDocument1.Print();
}
"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Randy, what are you doing in your Print Events? Could you post that code so we can see what is going on?

--
Greg Ewing [MVP]
http://www.citidc.com

"Randy" <na*****@hotmail.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has
about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I tried
using PrintPreviewDialog too but it still only shows just what is

visible in
the dialog that houses the dataGrid. I want to get all the datagrid

printed.
Maybe wrapping it would be the only way to print all of it...but I don't
know how to grab all the datagrid to the right, the part off screen.

Anyone
know how...
Thanks


Nov 15 '05 #3
I tried that way for myself, and don't like it at all. Here's perhaps a
better way, but I haven't tried this yet, either. It looks like it handles
rows better, but columns are probably limited to one page...

http://www.c-sharpcorner.com/Graphic...dPrinterMG.asp

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
"Randy" <na*****@hotmail.com> wrote in message
news:e2**************@TK2MSFTNGP11.phx.gbl...
Greg,
Sure, it is pretty simple (see below). I have the printDocument1 and the
bPrint button click event and then the printDocument1 printpage event...
Thanks

PrintDocument printDocument1 = new PrintDocument();

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

private void bPrint_Click(object sender, System.EventArgs e)
{
printDocument1.Print();
}
"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
Randy, what are you doing in your Print Events? Could you post that code
so
we can see what is going on?

--
Greg Ewing [MVP]
http://www.citidc.com

"Randy" <na*****@hotmail.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has
about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I

tried using PrintPreviewDialog too but it still only shows just what is

visible
in
the dialog that houses the dataGrid. I want to get all the datagrid

printed.
Maybe wrapping it would be the only way to print all of it...but I don't know how to grab all the datagrid to the right, the part off screen.

Anyone
know how...
Thanks



Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2275
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
0
2108
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
2
3436
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true...
0
1810
by: Nigel | last post by:
I successfully create a .NET Component (Visual Basic .NET) that would print, unfortunately when used within a web browser it appears that .NET security doesn't allow you to run code that interacts...
3
6272
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
1
2068
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
1
2874
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
8
2389
by: Rick Lederman | last post by:
I am using a PrintDocument and PrintDialog to print. The first time that I print it works, but when I try to print a second time without exiting the entire program I get an...
6
14892
by: randy1200 | last post by:
I'm using Visual Studio 2005 and C#. I need to print a WinForm used for data entry as a graphic. In other words, I need to print the exact WinForm the user sees on the screen. I searched through...
6
3227
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5697
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.