Format A4 size and form to print everything: labels, combobox, TextBox, everything ...

Answered Format A4 size and form to print everything: labels, combobox, TextBox, everything ...

  • Monday, April 02, 2012 10:15 PM
     
     
    My friends,

    I have a problem!
    I'm developing a project and would like to format the form, in order to remain the size of an A4 sheet, and print everything that appears there.

    How do I?

    greetings

All Replies

  • Tuesday, April 03, 2012 12:42 AM
     
     
    You have to design the form so it fits in the bounds of an A4 sheet.  You can then print it using the PrintForm component.
    • Proposed As Answer by btickle1 Tuesday, April 03, 2012 2:25 PM
    • Marked As Answer by Vitor Patrício Wednesday, April 04, 2012 8:19 PM
    • Unmarked As Answer by Vitor Patrício Friday, April 06, 2012 1:45 PM
    • Unproposed As Answer by Vitor Patrício Friday, April 06, 2012 2:03 PM
    •  
  • Tuesday, April 03, 2012 8:41 AM
     
     

    Hi,

    You can have all controls in a panel and that panel you can print.

    In print dialog box you can choose page type.

  • Tuesday, April 03, 2012 12:02 PM
     
     
    You can print every Form on an A4 sheet. It has to be scaled anyway.

    Armin

  • Tuesday, April 03, 2012 2:31 PM
     
     
    You can print every Form on an A4 sheet. It has to be scaled anyway.

    Armin


    Scaling a form for printing usually makes it unacceptable for quality.  You want to design it to use as much of the A4 sheet as possible.
  • Tuesday, April 03, 2012 3:07 PM
     
     

    Scaling a form for printing usually makes it unacceptable for quality.  You want to design it to use as much of the A4 sheet as possible.

    How can you do it without knowing the resolution of both devices? You can only say the larger the form the better the quality. Usually zooming in is a quality loss.

    Armin

  • Tuesday, April 03, 2012 3:10 PM
     
     

    "How can you do it without knowing the resolution of both devices?"

    The size of an A4 sheet is welll known.

  • Tuesday, April 03, 2012 3:13 PM
     
     
    I said resolution of devices, not size of the paper.

    Armin


  • Tuesday, April 03, 2012 3:29 PM
     
     
    Hello friend,

    Where do I change the scale to put A4 size.

    There is some code that does this?
  • Tuesday, April 03, 2012 3:33 PM
     
     
    Have you tried John's first suggestion?

    Armin

  • Tuesday, April 03, 2012 3:34 PM
     
     
    I said resolution of devices, not size of the paper.

    Armin


    That's the point.  The resolution of the devices is irrelevant.  The Form will be the same size on all devices.  For what it's worth, the printer resolution is always 1/100 inch. 
  • Tuesday, April 03, 2012 3:36 PM
     
     
    I said resolution of devices, not size of the paper.


    Our misunderstanding is probably that you consider dpi settings for both device, but I say you don't have to, so you can scale a 50x50px Form to A4 as well as a 2560x1600 form.

    EDIT: dpi settings for a screen are useless anyway. I'd have 101.6 ppi that can not be even set.


    Armin


  • Tuesday, April 03, 2012 3:38 PM
     
     
    The problem is how to design?
    What measures? Where to insert them without exceeding the A4?
  • Tuesday, April 03, 2012 3:39 PM
     
     

    I said resolution of devices, not size of the paper.


    Our misunderstanding is probably that you consider dpi settings for both device, but I say you don't have to, so you can scale a 50x50px Form to A4 as well as a 2560x1600 form.

    Armin

    The result of most discussions like this is circular:

    "Scaling a form for printing usually makes it unacceptable for quality.  You want to design it to use as much of the A4 sheet as possible"

  • Tuesday, April 03, 2012 3:47 PM
     
     
    Friend, you can put print screen or sample code?
  • Tuesday, April 03, 2012 3:50 PM
     
     
    Friend, you can put print screen or sample code?

    An A4 sheet is 8.3 X 11.7 inches or 830 X 1170 display units.  Make your form 830 X 1170 for portrait or 1170 X 830 for landscape.
    Adjust your form for any desired margins.
  • Tuesday, April 03, 2012 3:56 PM
     
     
    Friend, I have some difficulty. You can put the example screen print vb?
  • Tuesday, April 03, 2012 3:56 PM
     
     
    The point is that you can't "design for A4" as long as you don't know which scaling is performed when printing. This implies that scaling is unkown whereas you imply dpi aware scaling. No need to be as kind as you are often just because I try to explain our misunderstanding. Sure, quality depends on scaling, but that's nothing new and doesn't have to be repeated.

    Armin

  • Tuesday, April 03, 2012 3:59 PM
     
     

    An A4 sheet is 8.3 X 11.7 inches or 830 X 1170 display units.  Make your form 830 X 1170 for portrait or 1170 X 830 for landscape.

    Adjust your form for any desired margins.
    Why not make the Form bigger to get an even better quality? Printers do not have a fixed 100 dpi resolution BTW.

    Armin


  • Tuesday, April 03, 2012 4:04 PM
     
     
    Vb program in 2008 as it set up? Can you put here sample picture?
  • Tuesday, April 03, 2012 4:04 PM
     
     
    Vb program in 2008 as it set up? Can you put here sample picture?
  • Tuesday, April 03, 2012 4:06 PM
     
     
    Friend, I have some difficulty. You can put the example screen print vb?

    You can't design a Form to make it fit A4 becaues you can stretch or shrinken every Form to A4.


    Armin


  • Tuesday, April 03, 2012 4:09 PM
     
     
    Yes, but I set up form1, to make it the size of an A4 sheet?
  • Tuesday, April 03, 2012 4:10 PM
     
     
    Yes, but I set up form1, to make it the size of an A4 sheet?
  • Tuesday, April 03, 2012 4:17 PM
     
     
    Yes, but I set up form1, to make it the size of an A4 sheet?

    I'm afraid, this is not a question. Do you mean "how to set up the form..."? What you can do is use the same aspect ratio as an A4 sheet if you don't want to have borders at any side. So, design your form so that it's AR is 29.7 / 21. For example 594x420 pixels.

    EDIT: But be aware that a printer can have not-printable borders.

    Printing is another issue. It depends on how you do it. As I've asked you before: Have you already tried John's first suggestion? ("PrintForm component")


    Armin



    • Edited by Armin Zingler Tuesday, April 03, 2012 4:18 PM typo. "issue", not "use".
    • Edited by Armin Zingler Tuesday, April 03, 2012 4:19 PM
    • Marked As Answer by Vitor Patrício Wednesday, April 04, 2012 8:21 PM
    • Unmarked As Answer by Vitor Patrício Friday, April 06, 2012 1:46 PM
    •  
  • Tuesday, April 03, 2012 4:22 PM
     
     

  • Tuesday, April 03, 2012 4:22 PM
     
     
  • Tuesday, April 03, 2012 4:23 PM
     
     
    Public Class Form1


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        End Sub


        Private Sub Button1_Click(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles Button1.Click
            ' If you don't want the print button to print the print button
            Button1.Visible = False
            ' Set the PrintAction to display a Print Preview dialog
            PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
            ' This prints a copy of the form as it appears in the PrintPreview
            PrintForm1.Print()
            ' Display the print button again on the form
            Button1.Visible = True
        End Sub


        Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click


        End Sub
    End Class

  • Tuesday, April 03, 2012 4:25 PM
     
     
    Why does this happen. Why is cutting back on the right side? How do I set form1 toA4 and then to print?
  • Tuesday, April 03, 2012 4:32 PM
     
     
    Why does this happen. Why is cutting back on the right side? How do I set form1 toA4 and then to print?
    I don't know how to use the PrintForm component. Ask John. He's the specialist.

    Armin

  • Tuesday, April 03, 2012 6:44 PM
     
      Has Code
    Here's and example:
    Imports Microsoft.VisualBasic.PowerPacks.Printing
    Imports System.Drawing.Printing
    Imports System.IO
    Public Class Test
      Dim PF As New PrintForm
      Dim TB As New TextBox
      Dim WithEvents Tmr As New Timer
      Dim A4 As Size = New Size(830, 1170)
      Protected Overrides Sub OnLoad(e As System.EventArgs)
        MyBase.OnLoad(e)
        TB.Multiline = True
        TB.Font = New Font("Courier", 12)
        TB.Text = File.ReadAllText("..\..\Form1.vb")
        TB.Dock = DockStyle.Fill
        TB.Parent = Me
        PF.PrintAction = Printing.PrintAction.PrintToPreview
        PF.PrinterSettings.DefaultPageSettings.Landscape = True
        PF.PrinterSettings.DefaultPageSettings.Margins = New Margins(50, 50, 50, 50)
        Me.Size = New Size(A4.Height - 100, A4.Width - 100)
        PF.Form = Me
        Tmr.Start()
      End Sub
      Private Sub Tmr_Tick(sender As Object, e As EventArgs) Handles Tmr.Tick
        If Tmr.Tag Is Nothing Then
          Tmr.Tag = "Something"
          PF.Print()
        Else
          Tmr.Stop()
          For Each F As Form In Application.OpenForms
            If F.Text = "Print preview" Then F.ClientSize = A4
            Using Bmp As New Bitmap(A4.Width, A4.Height)
              F.DrawToBitmap(Bmp, New Rectangle(0, 0, A4.Width, A4.Height))
              Bmp.Save("Bmp.png")
            End Using
          Next
        End If
      End Sub
    End Class
    

  • Tuesday, April 03, 2012 11:07 PM
     
     
    The print preview that gives as an example occupies an A4 sheet altogether?
  • Tuesday, April 03, 2012 11:39 PM
     
     
  • Tuesday, April 03, 2012 11:40 PM
     
     
    Public Class Form1


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles Button1.Click
            ' If you don't want the print button to print the print button
            Button1.Visible = False
            ' Set the PrintAction to display a Print Preview dialog
            PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
            ' This prints a copy of the form as it appears in the PrintPreview
            PrintForm1.Print()
            ' Display the print button again on the form
            Button1.Visible = True
        End Sub
        Private Sub PrintForm1_QueryPageSettings(ByVal sender As Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles PrintForm1.QueryPageSettings
            Dim newMargins As System.Drawing.Printing.Margins
            newMargins = New System.Drawing.Printing.Margins(10, 10, 10, 10)
            e.PageSettings.Margins = newMargins
        End Sub


    End Class
  • Tuesday, April 03, 2012 11:45 PM
     
     
    With this code, which is somehow an adaptation of his, I got:
    as shown in Figure fill an entire print preview, but as yet to see a part below.
    How do I get full, also the part below?
  • Wednesday, April 04, 2012 1:03 AM
     
     
    With this code, which is somehow an adaptation of his, I got:
    as shown in Figure fill an entire print preview, but as yet to see a part below.
    How do I get full, also the part below?

    Are you sure that Your Form is less than the size of an A4 sheet?  What is the size of the Form?
  • Wednesday, April 04, 2012 1:54 AM
     
     
  • Wednesday, April 04, 2012 8:18 PM
     
     
    I'm still not sure, because print still nothing. But by appearance, seems to be an A4,but the print preview.

    Many thanks for your input so far. I am currently studying and test all materials. You are precious to me.

    hug
  • Wednesday, April 04, 2012 8:18 PM
     
     
    Many thanks for your input so far. I am currently studying and test all materials. You are precious to me.

    hug
  • Wednesday, April 04, 2012 8:19 PM
     
     
    Many thanks for your input so far. I am currently studying and test all materials. You are precious to me.

    hug
  • Wednesday, April 04, 2012 8:20 PM
     
     
    Many thanks for your input so far. I am currently studying and test all materials. You are precious to me.

    hug
  • Wednesday, April 04, 2012 8:38 PM
     
     
    Many thanks for your input so far. I am currently studying and test all materials. You are precious to me.

    hug
    It's very nice of you, but please do not mark all replies as the answer. It can confuse readers looking for the answer.

    Armin

  • Wednesday, April 04, 2012 8:52 PM
     
     

    Vitor,

    If you still need help please post a picture and the size of your form and I will try to code something for you.

    Good luck,

  • Wednesday, April 04, 2012 10:15 PM
     
     
    Ok friend.
    Grateful for the tip.
  • Wednesday, April 04, 2012 10:16 PM
     
     
    Grateful friend.
  • Monday, April 16, 2012 1:09 AM
     
     
  • Monday, April 16, 2012 4:48 AM
     
     

    Hi,

    Have you set the margins?

    And your form should be in panel whish will you print.

  • Monday, April 16, 2012 10:16 PM
     
     

    Can you help me, friend?

    greetings

  • Monday, April 16, 2012 10:19 PM
     
     

    Can you help me, friend?

    greetings

  • Monday, April 16, 2012 11:38 PM
     
     Answered

    Vitor,

    please use only one thread to discuss this. I have answered here:

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/3c1ca07e-1a85-45f9-a8bf-ccc64f1758af


    Armin

  • Sunday, June 10, 2012 11:01 PM
     
     

    Hello, friend.

    I am in need of your help in my thread:

    Center the text of a combobox Does it help me?

    greetings