473,416 Members | 1,738 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,416 software developers and data experts.

Select printer (chicken or egg) question.

I have a graphic file demo program that almost works. My form has a
PageSetupDialog, PrintPreview, PrintDialog, and a PrintDocument control.
Sample code follows.

Now here is the quesion. When I open the PrintDialog control, there is a
dropdown to select a printer from the list of available printers. However,
the PageSetupDialog sets the properties of the "selected" printer. How do I
find and select one of the available printers so I can , for example, select
the paper size and set up the page margins using the PageSetupDialog before I
select the printer using the PrintDialog?

More specifically, My default printer, a laserjet 4P only prints on 8 1/2 X
11 paper. I also have a HP5500C that can also print on 11 X 17 paper. Before
printing, I need to be able to select the HP500C so I then have the option to
select a 11X17 size and then set the print margins.

I hope this makes sense.

Hamil.
'************************************************* *******

Private PrintPageSettings As New PageSettings()

Private Sub btnPageSetup_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSetup.Click
Try
'Load page settings and display page setup dialog box
PageSetupDialog1.PageSettings = PrintPageSettings
PageSetupDialog1.ShowDialog()
Catch ex As Exception
'Display error message
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPreview.Click
Try
'Specify current page settings
PrintDocument1.DefaultPageSettings = PrintPageSettings
'Specify document for print preview dialog box and show
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
Catch ex As Exception
'Display error message
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim numChars As Integer
Dim numLines As Integer
Dim stringForPage As String
Dim strFormat As New StringFormat
'Based on page setup, define drawable rectangle on page
Dim rectDraw As New RectangleF( _
e.MarginBounds.Left, e.MarginBounds.Top, _
e.MarginBounds.Width, e.MarginBounds.Height)
e.Graphics.DrawImage(Image.FromFile("E:\MuView\Alt o1-1.tif"),
rectDraw)
End Sub

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrint.Click
Try
'Specify current page settings
PrintDocument1.DefaultPageSettings = PrintPageSettings
'Specify document for print dialog box and show
PrintDialog1.Document = PrintDocument1
Dim result As DialogResult = PrintDialog1.ShowDialog()
'If click OK, print document to printer
If result = DialogResult.OK Then
PrintDocument1.Print()
End If
Catch ex As Exception
'Display error message
MessageBox.Show(ex.Message)
End Try
End Sub
Nov 23 '05 #1
0 1434

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

Similar topics

2
by: adammitchell | last post by:
I'm trying to create a local copy of a popular CRM database called Salesforce.com. Many of the tables in the DB have FOREIGN KEY references that I want to preserve, but I've run into a chicken and...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
7
by: Jean Paul Mertens | last post by:
Hello, Is there a way to send a string of text to a generic tekst printer under ..NET. Somethings as in the good old days File f = Open("LPT1"); f.Writeline("Blablabla"); The goal is to use...
3
by: ASF | last post by:
General question here. You've been asked to develop an inhouse corporate app that is data-centric. Lots of editing, inserting, searching, and researching. How does your workflow and division of...
0
by: mafandon | last post by:
Hello all... My application uses custom reports from Microsoft's report viewer and not Crystal Reports. My understanding is there is no way to make the printdialog select a different printer...
4
by: Ian | last post by:
I have an Access 97 database, on a Report I have the print option set to print to the PC’s default printer rather than a printer selected from the list. My question is: Can I allow the user to...
4
by: Stef Mientki | last post by:
hello, after 4 months playing around with Python, and I still have troubles with egg files. Sometimes it works, sometimes it doesn't. If I google on "python egg", I get lost of links, which...
15
RMWChaos
by: RMWChaos | last post by:
In my ongoing effort to produce shorter, more efficient code, I have created a "chicken and egg" / "catch-22" problem. I can think of several ways to fix this, none of them elegant. I want my code...
8
by: Diggla | last post by:
I was asked to look into a performance problem on a newly migrated DB server. The db server was moved from a local-physical-nt4-sybase to remote (10 mb wan link), virtual, Windows 2003, SQL...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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...

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.