Solved

Set Papersize vb 2005 express

Posted on 2006-11-09
5
317 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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