473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Printing using the print dialog control in vb.net 2005

I have some sample code that uses the print dialog, print preview and a
print direct options.

If I select print preview and then click the printer icon from that, the
document prints. If I select the print directly option, it also prints right
away to the defauilt printer.

However, if I use the printer dialog control to print and I click 'OK' to
actually print the document - nothing happens. The job does not even go into
the print queue (I checked as I printed) No error messages are generated -
just nothing happens.

Any ideas?? PS (the page setup dialog control also does not print)

Here is the code...

Imports System.Drawing.Printing

Public Class Form1

Inherits System.Windows.Forms.Form

' Display a print preview.

Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrintPreview.Click

' Make a PrintDocument and attach it to

' the PrintPreview dialog.

dlgPrintPreview.Document = PreparePrintDocument()

' Preview.

dlgPrintPreview.WindowState = FormWindowState.Maximized

dlgPrintPreview.ShowDialog()

End Sub

' Print with the print dialog.

Private Sub btnPrintWithDialog_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnPrintWithDialog.Click

' Make a PrintDocument and attach it to

' the Print dialog.

dlgPrint.Document = PreparePrintDocument()

' Display the print dialog.

dlgPrint.ShowDialog()

End Sub

' Print immediately.

Private Sub btnPrintNow_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrintNow.Click

' Make a PrintDocument object.

Dim print_document As PrintDocument = PreparePrintDocument()

' Print immediately.

print_document.Print()

End Sub

' Make and return a PrintDocument object that's ready

' to print the paragraphs.

Private Function PreparePrintDocument() As PrintDocument

' Make the PrintDocument object.

Dim print_document As New PrintDocument

' Install the PrintPage event handler.

AddHandler print_document.PrintPage, AddressOf Print_PrintPage

' Return the object.

Return print_document

End Function

' Print the next page.

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs)

Dim imagePrint As Image = Image.FromFile("c:\gord.bmp")

e.Graphics.DrawImage(imagePrint, 50, 50, imagePrint.Width,
imagePrint.Height)

' No more pages

e.HasMorePages = False

End Sub

End Class

Mar 12 '07 #1
2 22094
Try calling the Print method on your Document after the dialog comes
back with an OK.

If dlgPrint.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
dlgPrint.Document.Print()
End If

======================
Clay Burch
Syncfusion, Inc.

Mar 13 '07 #2
Try calling the Print method on your Document after the dialog comes
back with an OK.

If dlgPrint.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
dlgPrint.Document.Print()
End If

======================
Clay Burch
Syncfusion, Inc.

Mar 13 '07 #3

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

Similar topics

9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
3
by: John Peterson | last post by:
Hello all! I'm at my wits end trying to search for what I assumed to be a relatively straightforward task. I have a Web application written in C#, and I have a button on the form that I want to...
1
by: Dreamtime | last post by:
Hi I am using Visual Studio 2005 and the bundled Crystal Reports (previously I used .net 2003 and bundled Crystal Reports for 2 years - same issues!) I have a report which is displayed in the...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
6
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...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
2
by: deepakfordotnet | last post by:
Hi, First of all let me confess that I could not get the solution to the same problem from an earlier post Printing :by Mr.Richard MSL (dated September 24th 2006) working. (Replied by Mr.Walter...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.