search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   HI

12/28/2005 7:24:55 PM    Problems printing
This piece of code prints out a image that I have placed on a  
  
picturebox. It currently prints it @ the top left hand side of the page.  
  
I want to know how I can control where in the page this image gets  
  
printed. Can anyone help? Thanks ;)  
  
William  
  
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As  
  
System.EventArgs) Handles btnPrint.Click  
  
Me.Close()  
  
'// insert code here to manage what to print //  
  
'// insert code here to manage what to print //  
  
' Declare the PrintDocument object.  
  
PrintDialog1.Document = docToPrint  
  
Dim result As DialogResult = PrintDialog1.ShowDialog()  
  
' If the result is OK then print the document.  
  
If (result = Windows.Forms.DialogResult.OK) Then  
  
docToPrint.Print()  
  
End If  
  
End Sub  
  
Private Sub docToPrint_PrintPage(ByVal sender As Object, ByVal e As  
  
Printing.PrintPageEventArgs) Handles docToPrint.PrintPage  
  
'e.Graphics.DrawString( text, printFont,  
  
System.Drawing.Brushes.Black, 100, 100)  
  
Dim mi As Reflection.MethodInfo = Form1.PictureBox1.GetType() _  
  
.GetMethod("OnPaint", Reflection.BindingFlags.Instance Or _  
  
Reflection.BindingFlags.NonPublic)  
  
Dim text As String = "In document_PrintPage method."  
  
Dim printFont As New System.Drawing.Font _  
  
("Arial", 35, System.Drawing.FontStyle.Regular)  
  
' Draw the content.  
  
e.Graphics.DrawString(text, printFont,  
  
System.Drawing.Brushes.Black, 0, 500)  
  
mi.Invoke(Form1.PictureBox1, New Object() {New  
  
PaintEventArgs(e.Graphics, New Rectangle(0, 0, 0, 0))})  
  
End Sub  
  
*** Sent via Developersdex http://www.developersdex.com ***


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.