Click here to Skip to main content
15,887,746 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: tif img print preview Pin
James.Cook201-Oct-14 3:54
James.Cook201-Oct-14 3:54 
QuestionCreate Image from Panel Control Pin
gwittlock27-Sep-14 9:02
gwittlock27-Sep-14 9:02 
AnswerRe: Create Image from Panel Control Pin
Eddy Vluggen27-Sep-14 13:40
professionalEddy Vluggen27-Sep-14 13:40 
GeneralRe: Create Image from Panel Control Pin
gwittlock27-Sep-14 15:23
gwittlock27-Sep-14 15:23 
GeneralRe: Create Image from Panel Control Pin
gwittlock27-Sep-14 21:27
gwittlock27-Sep-14 21:27 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen28-Sep-14 1:53
professionalEddy Vluggen28-Sep-14 1:53 
GeneralRe: Create Image from Panel Control Pin
gwittlock28-Sep-14 4:05
gwittlock28-Sep-14 4:05 
GeneralRe: Create Image from Panel Control Pin
drago1128-Sep-14 21:13
drago1128-Sep-14 21:13 
Hi Imports System.Drawing.Imaging
Imports System.Drawing.Printing





Private Sub PrintDocument1_PrintPage(ByVal Sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

Static page As Integer = 1

Dim startPosition As Integer = (page - 1) * PrintDocument1.DefaultPageSettings.Bounds.Height

Static maxPages As Integer = 0

If page = 1 Then

For Each ctrl As Control In Me.pRight19.Controls
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is Label Or TypeOf ctrl Is PictureBox Or TypeOf ctrl Is RichTextBox Then
ctrl.Tag = Int((ctrl.Top + ctrl.Height) / PrintDocument1.DefaultPageSettings.Bounds.Height) + 1
If CInt(ctrl.Tag) > maxPages Then maxPages = CInt(ctrl.Tag)
End If
Next

End If

For Each ctrl As Control In Me.pRight19.Controls
If CInt(ctrl.Tag) = page Then
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is Label Or TypeOf ctrl Is RichTextBox Then
Dim sf As New System.Drawing.StringFormat
If TypeOf ctrl Is TextBox Then
If DirectCast(ctrl, TextBox).TextAlign = HorizontalAlignment.Right Then
sf.Alignment = StringAlignment.Far
Else
sf.Alignment = StringAlignment.Near
End If
ElseIf TypeOf ctrl Is Label Then
If DirectCast(ctrl, Label).TextAlign = ContentAlignment.TopLeft Then
sf.Alignment = StringAlignment.Far
End If

ElseIf TypeOf ctrl Is RichTextBox Then
If DirectCast(ctrl, RichTextBox).SelectionAlignment = ContentAlignment.TopLeft Then
sf.Alignment = StringAlignment.Near
End If

End If
sf.FormatFlags = StringFormatFlags.NoClip
e.Graphics.DrawString(ctrl.Text, ctrl.Font, New SolidBrush(ctrl.ForeColor), New Rectangle(ctrl.Left, ctrl.Top - startPosition, ctrl.Width + 50, ctrl.Height), sf)
ElseIf TypeOf ctrl Is PictureBox Then
e.Graphics.DrawImage(DirectCast(ctrl, PictureBox).Image, New PointF(ctrl.Left, ctrl.Top - startPosition))

End If
End If
Next
page += 1
If page > maxPages Then
e.HasMorePages = False
page = 1
maxPages = 0
Else
e.HasMorePages = True
End If

End Sub



Private Sub ToolStripButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click



' PrintDocument1.Print()
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()

End Sub
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 3:21
gwittlock29-Sep-14 3:21 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen29-Sep-14 5:33
professionalEddy Vluggen29-Sep-14 5:33 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen28-Sep-14 22:12
professionalEddy Vluggen28-Sep-14 22:12 
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 3:19
gwittlock29-Sep-14 3:19 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen29-Sep-14 5:32
professionalEddy Vluggen29-Sep-14 5:32 
GeneralRe: Create Image from Panel Control Pin
gwittlock29-Sep-14 6:15
gwittlock29-Sep-14 6:15 
GeneralRe: Create Image from Panel Control Pin
gwittlock30-Sep-14 20:17
gwittlock30-Sep-14 20:17 
GeneralRe: Create Image from Panel Control Pin
Eddy Vluggen5-Oct-14 2:13
professionalEddy Vluggen5-Oct-14 2:13 
GeneralRe: Create Image from Panel Control Pin
gwittlock5-Oct-14 3:16
gwittlock5-Oct-14 3:16 
Questionvb Pin
Nishat Anwar27-Sep-14 6:41
Nishat Anwar27-Sep-14 6:41 
AnswerRe: vb Pin
Dave Kreskowiak27-Sep-14 6:47
mveDave Kreskowiak27-Sep-14 6:47 
QuestionRecommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta26-Sep-14 10:28
Vipul Mehta26-Sep-14 10:28 
AnswerRe: Recommendations on VB.Net to C# code conversion tool Pin
Tim Carmichael26-Sep-14 11:24
Tim Carmichael26-Sep-14 11:24 
GeneralRe: Recommendations on VB.Net to C# code conversion tool Pin
Vipul Mehta27-Sep-14 3:21
Vipul Mehta27-Sep-14 3:21 
QuestionFormatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259726-Sep-14 7:29
Member 1111259726-Sep-14 7:29 
AnswerRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Chris Quinn28-Sep-14 21:15
Chris Quinn28-Sep-14 21:15 
GeneralRe: Formatting Excel from Access: How do I apply conditional formatting with a loop? Pin
Member 1111259729-Sep-14 7:10
Member 1111259729-Sep-14 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.