|
-
Aug 24th, 2007, 04:48 PM
#1
Thread Starter
New Member
Datagridview print graphics
I used to use VS2003 and the DataGrid control. Now I have been using the VS 2005 DataGridView control (I don't even see the old DataGrid in the toolbox).
I accomplished printing a DataGrid as a Graphic (not text) with
public DataGrid gridtoprint = new DataGrid();
(blah, blah, other stuff to fill the grid)
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( gridtoprint, myPaintArgs );
}
But try this after simple substitution of:
public DataGridView gridtoprint = new DataGridView();
and some really weird things happen. Yes, the grid prints. But the elements are not in the cells. Instead, they are all packed into the top left corner of the grid in about 0.05 point type.
Is there a simple solution that allows my continued use of the new DataGridView control or do I need to go back to DataGrids for this functionality??
-
Aug 24th, 2007, 07:15 PM
#2
Re: Datagridview print graphics
That's a very inadvisable way to print a grid. What if there are more rows than can fit on the visible grid? There will be no way to print them. You should check out this thread. It provides an excepllent means to print the contents of DataGrids and DataGridViews. The code is VB but the principles are exactly the same. If you don't want to convert the code then just compile it into a VB DLL and use it from your C# app.
-
Aug 24th, 2007, 08:14 PM
#3
Thread Starter
New Member
Re: Datagridview print graphics
Thanks
I agree, and I have a good, working procedure for printing a grid.
However, I have an application where I want to print the grid as a graphic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|