473,396 Members | 1,722 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.

Need some help with using PageSetupSettings-dialog

Hi!

I have some problems with setting PrintDocument margins using
PageSetupDialog. Here some code to explain my problem...

First PrintDocument declaring this way...

Private pd As PrintDocument = New PrintDocument
It is possible to set default values for PrintDocument printing in
App.Config-file, and it contains following lines...

<add key="Printing.TopMargin" value="2" />
<add key="Printing.LeftMargin" value="7" />
<add key="Printing.BottomMargin" value="0" />
<add key="Printing.RightMargin" value="0" />
Application retrieves default values for PrintDocument when application
is started this way...

Private Sub frmLabels_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'// Get default settings for PrintDocument
With pd.DefaultPageSettings
.Margins.Top =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.TopMargin")) * 10
.Margins.Bottom =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.BottomMargin"))
* 10
.Margins.Right =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.RightMargin"))
* 10
.Margins.Left =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.LeftMargin")) * 10
'...
End With
End Sub
Here is how application uses PageSetupDialog to setup PrintDocument
settings...

Private Sub mnuPageSetup_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuPageSetup.Click
Try
Cursor = Cursors.WaitCursor
Dim dlg As PageSetupDialog = New PageSetupDialog

dlg.Document = pd
dlg.PrinterSettings = pd.PrinterSettings
Cursor = Cursors.Default

If (dlg.ShowDialog() = DialogResult.OK) Then
pd.PrinterSettings = dlg.PrinterSettings
End If

dlg.Dispose()

Catch ex As Exception
MessageBox.Show(ex.Message, "Error (mnuPageSetup_Click)",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
My problem is when user is clicking mnuPageSetup_Click first time
Margin-settings retrieved from App.Config are fine when PageSetupDialog
opens, but if user press OK-button and then turns back, Margin-settings
are not same any more after turning back, after this Margins
(millimeters)-frames orginal Left=7 will be 2,8 and original Top=2 will
be 0,8 in this case - why?

Ofcourse this was not happening if user pressed Cancel-button. Propably
I'm doing something wrong, but what? Anyway I'm getting printings fine.

By a way... 1cm = 0,3937" and 1" = 2,540005cm ...if needed :)

--
Thanks in advance!

Mika
Nov 21 '05 #1
1 1402
Well... I notices example code from
http://www.startvbdotnet.com/controls/printdialog1.aspx

....and changed mnuPageSetup_Click a little bit (see below between
previous message code lines), but it didn't solve my problem :(
Hi!

I have some problems with setting PrintDocument margins using
PageSetupDialog. Here some code to explain my problem...

First PrintDocument declaring this way...

Private pd As PrintDocument = New PrintDocument
It is possible to set default values for PrintDocument printing in
App.Config-file, and it contains following lines...

<add key="Printing.TopMargin" value="2" />
<add key="Printing.LeftMargin" value="7" />
<add key="Printing.BottomMargin" value="0" />
<add key="Printing.RightMargin" value="0" />
Application retrieves default values for PrintDocument when application
is started this way...

Private Sub frmLabels_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'// Get default settings for PrintDocument
With pd.DefaultPageSettings
.Margins.Top =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.TopMargin")) * 10
.Margins.Bottom =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.BottomMargin"))
* 10
.Margins.Right =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.RightMargin"))
* 10
.Margins.Left =
Integer.Parse(ConfigurationSettings.AppSettings("P rinting.LeftMargin"))
* 10
'...
End With
End Sub
Here is how application uses PageSetupDialog to setup PrintDocument
settings...

Private Sub mnuPageSetup_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuPageSetup.Click
Try
Cursor = Cursors.WaitCursor
Dim dlg As PageSetupDialog = New PageSetupDialog

dlg.Document = pd
dlg.PageSettings = pd.DefaultPageSettings
Cursor = Cursors.Default

If (dlg.ShowDialog() = DialogResult.OK) Then
pd.DefaultPageSettings = dlg.PageSettings
End If

dlg.Dispose()

Catch ex As Exception
MessageBox.Show(ex.Message, "Error (mnuPageSetup_Click)",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub


My problem is when user is clicking mnuPageSetup_Click first time
Margin-settings retrieved from App.Config are fine when PageSetupDialog
opens, but if user press OK-button and then turns back, Margin-settings
are not same any more after turning back, after this Margins
(millimeters)-frames orginal Left=7 will be 2,8 and original Top=2 will
be 0,8 in this case - why?

Ofcourse this was not happening if user pressed Cancel-button. Propably
I'm doing something wrong, but what? Anyway I'm getting printings fine.

By a way... 1cm = 0,3937" and 1" = 2,540005cm ...if needed :)

--
Thanks in advance!

Mika

Nov 21 '05 #2

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

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
7
by: Tee | last post by:
Hi, I need some help here for DSN connection string. I know it's not recommended to use DSN, even I dont like it as well ... but for now, my situation is I am using a shared hosting. I do not...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
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
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
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
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.