473,221 Members | 2,041 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,221 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 1392
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.