2013-07-18 84 views
0

後打印失敗的橫向模式我正在使用VB .NET編程,並且我想以橫向模式打印我的WinFormsApplication,因爲縱向模式無法正確適應它。VB .NET WinFormApplication在設置

我已經將橫向模式設置爲true。你可以參考下面的代碼:

Private Sub PrintAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    Handles PrintAll.Click 
    PrintForm1.Form = Me 
    PrintDocument1.DefaultPageSettings.Landscape = True 
    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.FullWindow) 
    PrintDialog1.ShowDialog() 
    End Sub 

而結果如下圖所示的截圖 http://s335.photobucket.com/user/blakeex/media/notcomplete.png.html 任何人都可以共享一些提示或引導?

回答

0

to print the complete client area of a scrollable form, even if the form has been resized.

嘗試PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)

這裏的另一種方式,將打印任何形式的部分是在屏幕上可見:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
    CaptureScreen() 
    PrintDocument1.DefaultPageSettings.Landscape = True 
    PrintDocument1.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0) 
    PrintDocument1.Print() 
End Sub 
Dim memoryImage As Bitmap 
Private Sub CaptureScreen() 
    Dim myGraphics As Graphics = Me.CreateGraphics() 
    Dim s As Size = Me.Size 
    memoryImage = New Bitmap(s.Width, s.Height, myGraphics) 
    Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage) 
    memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s) 
End Sub 
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage 
    Dim pagerec As New RectangleF(e.PageSettings.PrintableArea.X, e.PageSettings.PrintableArea.Y, e.PageSettings.PrintableArea.Height, e.PageSettings.PrintableArea.Width) 
    e.Graphics.DrawImage(memoryImage, pagerec, New Rectangle(Me.Location, Me.Size), GraphicsUnit.Pixel) 
End Sub 
+0

親愛@tinstaafl和別人的尊重的成員, 我已經嘗試過上述方法。 它不能正常工作,如下面的屏幕截圖網站所示: [http://s335.photobucket.com/user/blakeex/media/notcomplete-1.png.html] 你能否提出一個替代方案或讓我錯過了一步? – user2150279

+0

我添加了一個替代我的答案。 – tinstaafl