Solved

Set Papersize vb 2005 express

Posted on 2006-11-09
5
313 Views
Last Modified: 2012-06-27
This is the code I used ...
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim MyNormalFont As New Font("Arial", 8, FontStyle.Regular)
        Dim PaperK As New PaperKind
        Dim PaperS As New PaperSize
        PaperK = PaperKind.A4
        PaperS.RawKind = PaperK

        Me.PrintDocument1.DefaultPageSettings.Landscape = True
        Me.PrintDocument1.DefaultPageSettings.PaperSize = PaperS
        With Me.PrintDocument1.DefaultPageSettings.Margins
            .Bottom = 50
            .Left = 50
            .Right = 50
            .Top = 50
        End With
        Me.PrintPreviewDialog1.Document = Me.PrintDocument1
        Me.PrintPreviewDialog1.ShowDialog()

End Sub

But when I clicked the btnPrint ...

The papersize of the print preview becomes very small...

why?

What is the proper way of setting the papersize of the print preview to A4?

Jack...
0
Comment
Question by:JackOfPH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 500 total points
ID: 17905414
Hi JackOfPH,

Not sure on this one - but it could be your margin settings - default from memory is cm or inches - either of which is going to be a problem...

Also, try setting your DefaultPageSettings.PaperSize.Height and .Width values manually.

Cheers!
0
 
LVL 5

Expert Comment

by:maralans
ID: 17905829


        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Try
            PrintPreviewDialog1.Document = Me.PrintDocument1
            PrintPreviewDialog1.Width = intX
            PrintPreviewDialog1.Height = intY
            PrintPreviewDialog1.ShowDialog()
        Catch exp As Exception
            MessageBox.Show("An error occurred while trying to load the " & _
                "document for Print Preview. Make sure you currently have " & _
                "access to a printer. A printer must be connected and " & _
                "accessible for Print Preview to work.", Me.Text, _
                 MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
0
 
LVL 5

Expert Comment

by:maralans
ID: 17905977
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
       
        Dim MyNormalFont As New Font("Arial", 8, FontStyle.Regular)
        Dim PaperK As New Printing.PaperKind
        PaperK = Printing.PaperKind.A4

        Me.PrintDocument1.DefaultPageSettings.Landscape = True
        With Me.PrintDocument1.DefaultPageSettings.Margins
            .Bottom = 50
            .Left = 50
            .Right = 50
            .Top = 50
        End With
        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Try
            PrintPreviewDialog1.Document = Me.PrintDocument1
            PrintPreviewDialog1.Width = intX
            PrintPreviewDialog1.Height = intY
            PrintPreviewDialog1.ShowDialog()
        Catch exp As Exception
            MessageBox.Show("An error occurred while trying to load the " & _
                "document for Print Preview. Make sure you currently have " & _
                "access to a printer. A printer must be connected and " & _
                "accessible for Print Preview to work.", Me.Text, _
                 MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
0
 
LVL 5

Expert Comment

by:maralans
ID: 17909067
or:

PrintPreviewDialog1.Width = 700
PrintPreviewDialog1.Height = 500
PrintPreviewDialog1.ShowDialog()
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17910816
What would be the height and width of a A4 paper in hundredths of inches...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I copy a form and rename it in VS2015 2 32
visual studio vb.net windows onkeyup 2 40
VB.Net Data Class 1 48
CHANGE FORM TEXT BEFORE IT SHOW TO USER 13 33
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question