none
print a form but in lansscape

    Question

  • I am using the code below to print the image of my forms. The problem is some forms are wider than

    portrait width so they get cut off. Is there any way to to determine that in advance and force the print to landscape?

    Thanks much cyberal

    Code used shown below .............

    Imports System.Drawing.Printing
    Imports System.IO
    '
    Public Class Form3
        '4444444444444444444444444444444444444444444444444444444444444444444444444444444
        Inherits Form
        Private WithEvents printDocument1 As New PrintDocument
        Dim memoryImage As Bitmap
        Private Sub CaptureScreen()
            Dim myGraphics As Graphics = CreateGraphics()
            Dim s As Size = Size
            memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
            Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
            memoryGraphics.CopyFromScreen(Location.X, Location.Y, 0, 0, s)
        End Sub 'Sub 'CaptureScreen' Was at line: 14
        Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles printDocument1.PrintPage
            e.Graphics.DrawImage(memoryImage, 0, 0)
        End Sub 'Sub 'printDocument1_PrintPage' Was at line: 21
        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
            CaptureScreen()
            printDocument1.Print()
        End Sub 'Sub 'Button2_Click' Was at line: 24

    Sunday, March 19, 2017 7:18 PM

Answers

  • I modified your example so it rotates the image if it is wider than the printer margin. The hard part is just getting the correct units. So it does not change the printer settings to landscape it just prints the image landscape.

    Also I added print preview. I changed  the screen capture to use DrawToBitmap instead it seems easier?

    Imports System.Drawing.Printing
    Imports System.IO
    Public Class Form7
        Private WithEvents printDocument1 As New PrintDocument
        Private PrintPreviewDialog1 As New PrintPreviewDialog
        Dim memoryImage As Bitmap
        Private dpiXform As Single
    
        Private Sub CaptureScreen()
            Dim myGraphics As Graphics = CreateGraphics()
            'Dim s As Size = Size
            'memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
            'Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
            'memoryGraphics.CopyFromScreen(Location.X, Location.Y, 0, 0, s)
    
            dpiXform = myGraphics.DpiX
    
            'draw the form on the memory bitmap
            Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
            memoryImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(memoryImage, rect)
    
        End Sub 'Sub 'CaptureScreen' Was at line: 14
    
        Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles printDocument1.PrintPage
            Dim dpiXPrinter As Integer = CInt(e.Graphics.DpiX)
            Dim bmpInchesWidth As Single = CSng(memoryImage.Width / dpiXform)
    
            If bmpInchesWidth > e.MarginBounds.Width / 100 Then
                e.Graphics.TranslateTransform(e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height)
                e.Graphics.RotateTransform(-90)
            End If
            e.Graphics.DrawImage(memoryImage, 0, 0)
        End Sub 'Sub 'printDocument1_PrintPage' Was at line: 21
    
        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
            CaptureScreen()
            'printDocument1.Print()
    
            'show print preview with printdoc
            'click print icon button on print preview to print
            PrintPreviewDialog1.Document = printDocument1
            PrintPreviewDialog1.ShowDialog()
        End Sub 'Sub 'Butt
    
        Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ClientSize = New Size(800, 400)
        End Sub
    End Class

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Sunday, March 19, 2017 8:27 PM
  •  This seems to work pretty good for me.  It will also center the image of the form in the page as can be seen in the image below.  However,  you may want to take into account that if the form is big enough it might be longer than the page after it is rotated sideways.  In that case,  you would need to scale the image down to fit.  Just to keep the example easy to understand for now,  i did not add code for that.

     I used the DrawToBitmap method to create the image of the form just because it is a little easier and it will not capture any other forms or things that may be in front of the form.  It has a few advantages over the CaptureFromScreen method in some cases like this.

     Also,  you should be disposing of any New instances of Graphics objects,  Bitmap objects,  and other controls like the PrintPreviewDialog and PrintDocument when they are no longer needed.

    Imports System.ComponentModel
    Imports System.Drawing.Printing
    
    Public Class Form1
        Private WithEvents PrintDocument1 As New PrintDocument
        Private PrintPreviewDialog1 As New PrintPreviewDialog With {.Document = PrintDocument1}
        Private FormImage As Bitmap = Nothing
    
        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))
    
            PrintPreviewDialog1.ShowDialog()
        End Sub
    
        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            If FormImage.Width > e.MarginBounds.Width Then FormImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
    
            Dim CenterBounds As Rectangle
            CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (FormImage.Width \ 2))
            CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (FormImage.Height \ 2))
            CenterBounds.Width = FormImage.Width
            CenterBounds.Height = FormImage.Height
    
            e.Graphics.DrawImage(FormImage, CenterBounds)
        End Sub
    
        Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
            'When the Form is closing, Dispose all these new class scoped objects that you have created new instances of.
            PrintDocument1.Dispose()
            PrintPreviewDialog1.Dispose()
            If FormImage IsNot Nothing Then FormImage.Dispose()
        End Sub
    End Class
     

     


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Monday, March 20, 2017 12:46 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Monday, March 20, 2017 12:15 AM
  •  With a little checking,  it seems you can set the Size or the WindowState of the PrintPreviewDialog as shown below.  Most .net dialogs don`t have this capability but,  surprise.... the PrintPreviewDialog does.

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))

            'PrintPreviewDialog1.Size = New Size(800, 600) 'set a new size for the dialog

            'OR... maximize the dialog window
            PrintPreviewDialog1.WindowState = FormWindowState.Maximized 'maximize the dialog

            PrintPreviewDialog1.ShowDialog()
        End Sub


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, March 25, 2017 12:43 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Saturday, March 25, 2017 12:40 AM
  •  I modified the PrintDocument1 PrintPage event sub so that it will scale the image down if the image is to big to fit in the page as i was mentioning in my last post.  You would only need to change the sub below in the example from my last post to do this.

      Scaling the image down could be done a few ways so,  this is just one way you can do it.  However,  be aware that if you have smaller text on your form it may be distorted when it is scaled down like this.  There is not a lot you can do about that other than print to a bigger page size so that it does not get scaled down or at least not as much.

        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            If FormImage.Width > FormImage.Height AndAlso FormImage.Width > e.MarginBounds.Width Then
                FormImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
            End If

            Dim CenterBounds As Rectangle
            CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (FormImage.Width \ 2))
            CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (FormImage.Height \ 2))
            CenterBounds.Width = FormImage.Width
            CenterBounds.Height = FormImage.Height

            Dim ratio As Double = FormImage.Width / FormImage.Height

            If CenterBounds.Width > e.MarginBounds.Width Then
                CenterBounds.Width = e.MarginBounds.Width
                CenterBounds.Height = CInt(CenterBounds.Width / ratio)
                CenterBounds.X = e.MarginBounds.Left
                CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (CenterBounds.Height \ 2))
            End If

            If CenterBounds.Height > e.MarginBounds.Height Then
                CenterBounds.Height = e.MarginBounds.Height
                CenterBounds.Width = CInt(CenterBounds.Height * ratio)
                CenterBounds.Y = e.MarginBounds.Top
                CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (CenterBounds.Width \ 2))
            End If

            e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
            e.Graphics.DrawImage(FormImage, CenterBounds)
        End Sub
     

     I resized my form width to 1280,  the full width of my screen for this test.  You can see that the form is scaled down smaller than in the image from my last post so it will fit in the margins of the page.


    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Monday, March 20, 2017 1:51 AM
  • So sorry I did not get back to you. I was called out out of town on personal business.

    I did try your solution quickly on all my forms (10) and all but one worked. Not sure why so I am looking into tomorrow. It flips it fine but doesn't show any of the labels, textboxes, radio buttons, buttons etc.  it is just blank. There are a lot of these objects on the form. for example about 100 textboxes.

    Will continue looking into this in the morning.

    If you have any quick suggestions that would be great.

    Again, thanks much for your help

    Cyberal

    Which example are you using? My example and Razerz 1 draws with a 1:1 pixel ratio, so if your form pixels are larger than the print margins you may have some areas cut off of the print page.

    Razerz example 2 resizes the image to fit the page margins.

    Is that the problem, the form is too large?

    If not you need to give more info. Maybe a screen shot of the form, describe the controls as req'd. Provide any code needed to see what you are doing exactly to guess why some of the form is not drawn. Does the captured bitmap have all the form controls and area? You may need to show it in a picturebox to see what you are capturing.

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Thursday, March 23, 2017 2:30 PM
  • I was using the Razerz example 2. See image of form attached. The output is of the form did rotate properly but absolutely nothing showing except its' outline. It is just empty.

    I am in no hurry so if you have something more pressing, just take your time.

    Thanks for your help.

    Cyberal

     We can not see your image.  You may need to use a site like TinyPic.com or similar type site to show us an image.  You also have not shown us how you are using the code to print the forms.  We will need to see that code.

     If it is printing all your forms except just this one form,  there must be something that is different about the form than the rest.  Weather,  it is a property you have changed in this form or maybe the code you are using to print this one form that is causing the problem we can not say without seeing the code.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Thursday, March 23, 2017 8:57 PM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Thursday, March 23, 2017 8:56 PM
  • I got it to work.

     It was something on the form itself.  I created a new form and copied everything from the old form to it. I have no idea what it was, something that could not be seen on the old form. Go figure...  Your code worked perfectly.

    Have another question. When the print preview comes up, is there any way to get it to be larger by default or must one rely on the buttons on the form.

    Definitely appreciate your help

    Cyberal

     If one or more posts have answered your original question,  then please remember to mark the post or posts that answered it as the answer(s).

     For your second question,  i don`t know what you mean by "rely on the buttons".  I also don't know what you mean by making it larger.  Do you mean the Dialog window itself or the page that it is displaying to print?  I don`t know of an easy way of doing either right off hand.


    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Friday, March 24, 2017 11:41 PM
  •  With a little checking,  it seems you can set the size of the PrintPreviewDialog as shown below.  Most .net dialogs don`t have this capability but,  surprise.... the PrintPreviewDialog does.

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))
    
            PrintPreviewDialog1.Size = New Size(800, 600) 'set a new size for the dialog
    
            PrintPreviewDialog1.ShowDialog()
        End Sub


    If you say it can`t be done then i`ll try it

    Oooh... Good one Razerz!

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Saturday, March 25, 2017 12:49 AM
  • Oooh... Good one Razerz!

     I believe i said there was not an easy strait forward way to do this a month or two ago in a similar question.  Now i feel like a liar.  haha  8)

     PS - I edited that post,  you can set the WindowState too.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, March 25, 2017 12:55 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:53 PM
    Saturday, March 25, 2017 12:53 AM
  • Worked perfectly. Thank you so much. I tried different sizes and maximized window.

    I will mark this as answered

    Cyberal


     You are suppose to mark the post or posts of the person or persons that answered your question as the answer(s),  not mark your own post as the answer.

    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:53 PM
    Saturday, March 25, 2017 10:07 PM

All replies

  • I modified your example so it rotates the image if it is wider than the printer margin. The hard part is just getting the correct units. So it does not change the printer settings to landscape it just prints the image landscape.

    Also I added print preview. I changed  the screen capture to use DrawToBitmap instead it seems easier?

    Imports System.Drawing.Printing
    Imports System.IO
    Public Class Form7
        Private WithEvents printDocument1 As New PrintDocument
        Private PrintPreviewDialog1 As New PrintPreviewDialog
        Dim memoryImage As Bitmap
        Private dpiXform As Single
    
        Private Sub CaptureScreen()
            Dim myGraphics As Graphics = CreateGraphics()
            'Dim s As Size = Size
            'memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
            'Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
            'memoryGraphics.CopyFromScreen(Location.X, Location.Y, 0, 0, s)
    
            dpiXform = myGraphics.DpiX
    
            'draw the form on the memory bitmap
            Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
            memoryImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(memoryImage, rect)
    
        End Sub 'Sub 'CaptureScreen' Was at line: 14
    
        Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles printDocument1.PrintPage
            Dim dpiXPrinter As Integer = CInt(e.Graphics.DpiX)
            Dim bmpInchesWidth As Single = CSng(memoryImage.Width / dpiXform)
    
            If bmpInchesWidth > e.MarginBounds.Width / 100 Then
                e.Graphics.TranslateTransform(e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height)
                e.Graphics.RotateTransform(-90)
            End If
            e.Graphics.DrawImage(memoryImage, 0, 0)
        End Sub 'Sub 'printDocument1_PrintPage' Was at line: 21
    
        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
            CaptureScreen()
            'printDocument1.Print()
    
            'show print preview with printdoc
            'click print icon button on print preview to print
            PrintPreviewDialog1.Document = printDocument1
            PrintPreviewDialog1.ShowDialog()
        End Sub 'Sub 'Butt
    
        Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ClientSize = New Size(800, 400)
        End Sub
    End Class

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Sunday, March 19, 2017 8:27 PM
  •  This seems to work pretty good for me.  It will also center the image of the form in the page as can be seen in the image below.  However,  you may want to take into account that if the form is big enough it might be longer than the page after it is rotated sideways.  In that case,  you would need to scale the image down to fit.  Just to keep the example easy to understand for now,  i did not add code for that.

     I used the DrawToBitmap method to create the image of the form just because it is a little easier and it will not capture any other forms or things that may be in front of the form.  It has a few advantages over the CaptureFromScreen method in some cases like this.

     Also,  you should be disposing of any New instances of Graphics objects,  Bitmap objects,  and other controls like the PrintPreviewDialog and PrintDocument when they are no longer needed.

    Imports System.ComponentModel
    Imports System.Drawing.Printing
    
    Public Class Form1
        Private WithEvents PrintDocument1 As New PrintDocument
        Private PrintPreviewDialog1 As New PrintPreviewDialog With {.Document = PrintDocument1}
        Private FormImage As Bitmap = Nothing
    
        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))
    
            PrintPreviewDialog1.ShowDialog()
        End Sub
    
        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            If FormImage.Width > e.MarginBounds.Width Then FormImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
    
            Dim CenterBounds As Rectangle
            CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (FormImage.Width \ 2))
            CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (FormImage.Height \ 2))
            CenterBounds.Width = FormImage.Width
            CenterBounds.Height = FormImage.Height
    
            e.Graphics.DrawImage(FormImage, CenterBounds)
        End Sub
    
        Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
            'When the Form is closing, Dispose all these new class scoped objects that you have created new instances of.
            PrintDocument1.Dispose()
            PrintPreviewDialog1.Dispose()
            If FormImage IsNot Nothing Then FormImage.Dispose()
        End Sub
    End Class
     

     


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Monday, March 20, 2017 12:46 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Monday, March 20, 2017 12:15 AM
  •  I modified the PrintDocument1 PrintPage event sub so that it will scale the image down if the image is to big to fit in the page as i was mentioning in my last post.  You would only need to change the sub below in the example from my last post to do this.

      Scaling the image down could be done a few ways so,  this is just one way you can do it.  However,  be aware that if you have smaller text on your form it may be distorted when it is scaled down like this.  There is not a lot you can do about that other than print to a bigger page size so that it does not get scaled down or at least not as much.

        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
            If FormImage.Width > FormImage.Height AndAlso FormImage.Width > e.MarginBounds.Width Then
                FormImage.RotateFlip(RotateFlipType.Rotate90FlipNone)
            End If

            Dim CenterBounds As Rectangle
            CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (FormImage.Width \ 2))
            CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (FormImage.Height \ 2))
            CenterBounds.Width = FormImage.Width
            CenterBounds.Height = FormImage.Height

            Dim ratio As Double = FormImage.Width / FormImage.Height

            If CenterBounds.Width > e.MarginBounds.Width Then
                CenterBounds.Width = e.MarginBounds.Width
                CenterBounds.Height = CInt(CenterBounds.Width / ratio)
                CenterBounds.X = e.MarginBounds.Left
                CenterBounds.Y = e.MarginBounds.Top + ((e.MarginBounds.Height \ 2) - (CenterBounds.Height \ 2))
            End If

            If CenterBounds.Height > e.MarginBounds.Height Then
                CenterBounds.Height = e.MarginBounds.Height
                CenterBounds.Width = CInt(CenterBounds.Height * ratio)
                CenterBounds.Y = e.MarginBounds.Top
                CenterBounds.X = e.MarginBounds.Left + ((e.MarginBounds.Width \ 2) - (CenterBounds.Width \ 2))
            End If

            e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
            e.Graphics.DrawImage(FormImage, CenterBounds)
        End Sub
     

     I resized my form width to 1280,  the full width of my screen for this test.  You can see that the form is scaled down smaller than in the image from my last post so it will fit in the margins of the page.


    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Monday, March 20, 2017 1:51 AM
  • So sorry I did not get back to you. I was called out out of town on personal business.

    I did try your solution quickly on all my forms (10) and all but one worked. Not sure why so I am looking into tomorrow. It flips it fine but doesn't show any of the labels, textboxes, radio buttons, buttons etc.  it is just blank. There are a lot of these objects on the form. for example about 100 textboxes.

    Will continue looking into this in the morning.

    If you have any quick suggestions that would be great.

    Again, thanks much for your help

    Cyberal

    Wednesday, March 22, 2017 10:08 PM
  • So sorry I did not get back to you. I was called out out of town on personal business.

    I did try your solution quickly on all my forms (10) and all but one worked. Not sure why so I am looking into tomorrow. It flips it fine but doesn't show any of the labels, textboxes, radio buttons, buttons etc.  it is just blank. There are a lot of these objects on the form. for example about 100 textboxes.

    Will continue looking into this in the morning.

    If you have any quick suggestions that would be great.

    Again, thanks much for your help

    Cyberal

    Which example are you using? My example and Razerz 1 draws with a 1:1 pixel ratio, so if your form pixels are larger than the print margins you may have some areas cut off of the print page.

    Razerz example 2 resizes the image to fit the page margins.

    Is that the problem, the form is too large?

    If not you need to give more info. Maybe a screen shot of the form, describe the controls as req'd. Provide any code needed to see what you are doing exactly to guess why some of the form is not drawn. Does the captured bitmap have all the form controls and area? You may need to show it in a picturebox to see what you are capturing.

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Thursday, March 23, 2017 2:30 PM
  • I was using the Razerz example 2. See image of form attached. The output is of the form did rotate properly but absolutely nothing showing except its' outline. It is just empty.

    I am in no hurry so if you have something more pressing, just take your time.

    Thanks for your help.

    Cyberal

    Thursday, March 23, 2017 8:07 PM
  • I was using the Razerz example 2. See image of form attached. The output is of the form did rotate properly but absolutely nothing showing except its' outline. It is just empty.

    I am in no hurry so if you have something more pressing, just take your time.

    Thanks for your help.

    Cyberal

     We can not see your image.  You may need to use a site like TinyPic.com or similar type site to show us an image.  You also have not shown us how you are using the code to print the forms.  We will need to see that code.

     If it is printing all your forms except just this one form,  there must be something that is different about the form than the rest.  Weather,  it is a property you have changed in this form or maybe the code you are using to print this one form that is causing the problem we can not say without seeing the code.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Thursday, March 23, 2017 8:57 PM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Thursday, March 23, 2017 8:56 PM
  • I got it to work.

     It was something on the form itself.  I created a new form and copied everything from the old form to it. I have no idea what it was, something that could not be seen on the old form. Go figure...  Your code worked perfectly.

    Have another question. When the print preview comes up, is there any way to get it to be larger by default or must one rely on the buttons on the form.

    Definitely appreciate your help

    Cyberal

    Friday, March 24, 2017 10:57 PM
  • I got it to work.

     It was something on the form itself.  I created a new form and copied everything from the old form to it. I have no idea what it was, something that could not be seen on the old form. Go figure...  Your code worked perfectly.

    Have another question. When the print preview comes up, is there any way to get it to be larger by default or must one rely on the buttons on the form.

    Definitely appreciate your help

    Cyberal

     If one or more posts have answered your original question,  then please remember to mark the post or posts that answered it as the answer(s).

     For your second question,  i don`t know what you mean by "rely on the buttons".  I also don't know what you mean by making it larger.  Do you mean the Dialog window itself or the page that it is displaying to print?  I don`t know of an easy way of doing either right off hand.


    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Friday, March 24, 2017 11:41 PM
  •  With a little checking,  it seems you can set the Size or the WindowState of the PrintPreviewDialog as shown below.  Most .net dialogs don`t have this capability but,  surprise.... the PrintPreviewDialog does.

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))

            'PrintPreviewDialog1.Size = New Size(800, 600) 'set a new size for the dialog

            'OR... maximize the dialog window
            PrintPreviewDialog1.WindowState = FormWindowState.Maximized 'maximize the dialog

            PrintPreviewDialog1.ShowDialog()
        End Sub


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, March 25, 2017 12:43 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Saturday, March 25, 2017 12:40 AM
  •  With a little checking,  it seems you can set the size of the PrintPreviewDialog as shown below.  Most .net dialogs don`t have this capability but,  surprise.... the PrintPreviewDialog does.

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            If FormImage IsNot Nothing Then FormImage.Dispose()
            FormImage = New Bitmap(Me.Width, Me.Height)
            Me.DrawToBitmap(FormImage, New Rectangle(0, 0, Me.Width, Me.Height))
    
            PrintPreviewDialog1.Size = New Size(800, 600) 'set a new size for the dialog
    
            PrintPreviewDialog1.ShowDialog()
        End Sub


    If you say it can`t be done then i`ll try it

    Oooh... Good one Razerz!

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Saturday, March 25, 2017 12:49 AM
  • Oooh... Good one Razerz!

     I believe i said there was not an easy strait forward way to do this a month or two ago in a similar question.  Now i feel like a liar.  haha  8)

     PS - I edited that post,  you can set the WindowState too.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, March 25, 2017 12:55 AM
    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:53 PM
    Saturday, March 25, 2017 12:53 AM
  • Worked perfectly. Thank you so much. I tried different sizes and maximized window.

    I will mark this as answered

    Cyberal

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 5:57 PM
    • Unmarked as answer by cyberal1043 Saturday, March 25, 2017 10:54 PM
    Saturday, March 25, 2017 5:57 PM
  • Just noticed TommyTwoTrain and Sandia Software. That in Albuquerque by chance? Lived in Corrales and Rio Rancho for over 20 years. Would love to get back there. We really miss it.

    Cyberal

    Saturday, March 25, 2017 6:04 PM
  • Worked perfectly. Thank you so much. I tried different sizes and maximized window.

    I will mark this as answered

    Cyberal


     You are suppose to mark the post or posts of the person or persons that answered your question as the answer(s),  not mark your own post as the answer.

    If you say it can`t be done then i`ll try it

    • Marked as answer by cyberal1043 Saturday, March 25, 2017 10:53 PM
    Saturday, March 25, 2017 10:07 PM
  • Just noticed TommyTwoTrain and Sandia Software. That in Albuquerque by chance? Lived in Corrales and Rio Rancho for over 20 years. Would love to get back there. We really miss it.

    Cyberal

    Hi,

    Yes I am in Los Ranchos area.

    Saturday, March 25, 2017 11:24 PM