Guten Tag Zusammen
Habe wieder was, Ich hab eine Funktion die mir Textboxen auf ein vordefiniertes Formular druckt. Wollte mal fragen ob man das abgreifen kann um eine Vorschau zu erstellen welche runterskaliert ist. Weil als BG ein vorgeschriebenes png genutzt wird in voller A4 Grösse kann man das nicht in einer Form oder sonst wie darstellen. Wer sich das wirklich antun will hier ist der Code beim Drucken:
Spoiler anzeigen
Habe wieder was, Ich hab eine Funktion die mir Textboxen auf ein vordefiniertes Formular druckt. Wollte mal fragen ob man das abgreifen kann um eine Vorschau zu erstellen welche runterskaliert ist. Weil als BG ein vorgeschriebenes png genutzt wird in voller A4 Grösse kann man das nicht in einer Form oder sonst wie darstellen. Wer sich das wirklich antun will hier ist der Code beim Drucken:
Quellcode
- Private Sub Button23_Click(sender As System.Object, e As System.EventArgs) Handles Button23.Click
- If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
- PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
- PrintDocument1.Print()
- End If
- End Sub
- Public Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
- ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
- Handles PrintDocument1.PrintPage
- e.Graphics.DrawImage(Druckvorschau.PictureBox1.Image, 0, 0)
- Try
- Try
- 'RichTextbox *****
- No1 = False
- Dim str As String = RichTextBox1.Text
- Dim splitStr As String() = str.Split(","c)
- Dim i As Integer
- Dim String1 As String
- Dim String2 As String
- Dim String3 As String
- Dim Gesamtstring1 As String
- String1 = splitStr(0).ToString()
- String2 = splitStr(1).ToString()
- String3 = splitStr(2).ToString()
- Gesamtstring1 = splitStr(i) + Environment.NewLine + String2 + Environment.NewLine + String3
- e.Graphics.DrawString(Gesamtstring1, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 200))
- No1 = True
- 'RichtTextbox ***** Ende
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No1 = True
- End Try
- Try
- 'RichTextbox ******
- No2 = False
- Dim str2 As String = RichTextBox2.Text
- Dim splitStr2 As String() = str2.Split(","c)
- Dim String21 As String
- Dim String22 As String
- Dim String23 As String
- Dim Gesamtstring2 As String
- String21 = splitStr2(0).ToString()
- String22 = splitStr2(1).ToString()
- String23 = splitStr2(2).ToString()
- Gesamtstring2 = String21 + Environment.NewLine + String22 + Environment.NewLine + String23
- e.Graphics.DrawString(Gesamtstring2, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 300))
- No2 = True
- 'RichtTextbox ****** Ende
- Catch
- MsgBox("Der Text aus dem Feld ****** konnte nicht übergeben werden")
- No2 = True
- End Try
- Try
- No3 = False
- 'RichTextbox ******
- Dim str3 As String = RichTextBox3.Text
- e.Graphics.DrawString(str3, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 400))
- 'RichtTextbox ****** Ende
- No3 = True
- Catch
- MsgBox("Der Text aus dem Feld des ****** konnte nicht übergeben werden")
- No3 = True
- End Try
- Try
- No4 = False
- 'RichTextbox *****
- Dim str4 As String = RichTextBox4.Text
- Dim str41 As String = DateTimePicker2.Text
- e.Graphics.DrawString(str4, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 465))
- e.Graphics.DrawString(str41, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 480))
- 'RichtTextbox ******
- No4 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No4 = True
- End Try
- 'Beigefügte Dokumente
- Try
- No5 = False
- If RichTextBox5.Text.Contains(",") Then
- Dim str9 As String = RichTextBox5.Text
- Dim splitStr9 As String() = str9.Split(","c)
- Dim Gesamtstring7 As String
- Gesamtstring7 = ""
- For Each c In splitStr9
- Gesamtstring7 &= c & Environment.NewLine
- Next
- e.Graphics.DrawString(Gesamtstring7, New Font("Franklin Gothic Book", 9), Brushes.Black, New Point(90, 535))
- Else
- Dim str9 As String = RichTextBox5.Text
- e.Graphics.DrawString(str9, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 535))
- End If
- No5 = True
- Catch
- MsgBox("Der Text aus dem Feld der beigefügten Dokumente konnte nicht übergeben werden")
- No5 = True
- End Try
- 'Beigefügte Dokumente Ende
- Try
- No6 = False
- 'RichTextbox*******
- Dim str6 As String = RichTextBox6.Text
- Dim splitStr6 As String() = str6.Split(","c)
- Dim String61 As String
- Dim String62 As String
- Dim String63 As String
- Dim Gesamtstring6 As String
- String61 = splitStr6(0).ToString()
- String62 = splitStr6(1).ToString()
- String63 = splitStr6(2).ToString()
- Gesamtstring6 = String61 + Environment.NewLine + String62 + Environment.NewLine + String63
- e.Graphics.DrawString(Gesamtstring6, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(450, 300))
- 'RichtTextbox *****
- No6 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No6 = True
- End Try
- Try
- No7 = False
- 'RichTextbox *****
- Dim str7 As String = RichTextBox7.Text
- Dim splitStr7 As String() = str7.Split(","c)
- Dim String71 As String
- Dim String72 As String
- Dim String73 As String
- Dim Gesamtstring7 As String
- String71 = splitStr7(0).ToString()
- String72 = splitStr7(1).ToString()
- String73 = splitStr7(2).ToString()
- Gesamtstring7 = String71 + Environment.NewLine + String72 + Environment.NewLine + String73
- e.Graphics.DrawString(Gesamtstring7, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(450, 400))
- 'RichtTextbox ******
- No7 = True
- Catch
- MsgBox("Der Text aus dem Feld ****** konnte nicht übergeben werden")
- No7 = True
- End Try
- Try
- No8 = False
- 'RichTextbox *****
- Dim str8 As String = RichTextBox8.Text
- e.Graphics.DrawString(str8, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(450, 510))
- 'RichtTextbox *****
- No8 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No8 = True
- End Try
- Try
- No9 = False
- 'RichTextbox *****
- Dim str9 As String = TextBox9.Text
- e.Graphics.DrawString(str9, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(85, 600))
- 'RichtTextbox ***** Ende
- No9 = True
- Catch
- MsgBox("Der Text aus dem Feld ****** konnte nicht übergeben werden")
- No9 = True
- End Try
- Try
- No10 = False
- 'RichTextbox *****
- Dim str11 As String = ComboBox1.Text
- Dim str10 As String = TextBox1.Text
- e.Graphics.DrawString(str10, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(200, 600))
- e.Graphics.DrawString(str11, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(240, 600))
- 'RichtTextbox ***** Ende
- No10 = True
- Catch
- MsgBox("Der Text aus dem Feld ****** konnte nicht übergeben werden")
- No10 = True
- End Try
- Try
- No11 = False
- 'Richtextbox *****
- Dim Str12 As String = ComboBox10.Text
- e.Graphics.DrawString(Str12, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(290, 600))
- 'RichTextBox ***** Ende
- No11 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No11 = True
- End Try
- Try
- No12 = False
- 'Richtextbox *****
- Dim Str12 As String = ComboBox11.Text
- e.Graphics.DrawString(Str12, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(440, 600))
- 'RichTextBox ***** Ende
- No12 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No12 = True
- End Try
- Try
- No13 = False
- 'Richtextbox *****
- Dim Str13 As String = ComboBox12.Text
- e.Graphics.DrawString(Str13, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(550, 600))
- 'RichTextBox ***** Ende
- No13 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No13 = True
- End Try
- Try
- No14 = False
- 'Richtextbox *****
- Dim Str14 As String = TextBox10.Text
- e.Graphics.DrawString(Str14, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(640, 600))
- 'RichTextBox ***** Ende
- No14 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No14 = True
- End Try
- Try
- No15 = False
- 'Richtextbox *****
- Dim Str15 As String = TextBox11.Text
- e.Graphics.DrawString(Str15, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(740, 600))
- 'RichTextBox ***** Ende
- No15 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No15 = True
- End Try
- Try
- No16 = False
- 'Richtextbox *****
- Dim Str16 As String = RichTextBox9.Text
- e.Graphics.DrawString(Str16, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 770))
- 'RichTextBox ***** Ende
- No16 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No16 = True
- End Try
- Try
- No17 = False
- 'Richtextbox *****
- If CheckBox1.Checked = True Then
- Dim Str17 As String = "✔"
- e.Graphics.DrawString(Str17, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(285, 880))
- 'RichTextBox ***** Ende
- No17 = True
- End If
- If CheckBox1.Checked = False Then
- No17 = True
- End If
- Catch
- No17 = True
- End Try
- Try
- No18 = False
- 'Richtextbox *****
- If RadioButton1.Checked = True Then
- Dim Str18 As String = "✔"
- e.Graphics.DrawString(Str18, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(120, 915))
- 'RichTextBox *****
- No18 = True
- End If
- If RadioButton2.Checked = True Then
- Dim Str19 As String = "✔"
- e.Graphics.DrawString(Str19, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(120, 930))
- 'RichTextBox *****
- No18 = True
- End If
- Catch
- No18 = True
- End Try
- Try
- No19 = False
- 'Richtextbox *****
- Dim Str20 As String = RichTextBox13.Text
- Dim Str21 As String = RichTextBox11.Text
- Dim Str22 As String = TextBox2.Text
- Dim Str23 As String = TextBox3.Text
- Dim Str24 As String = TextBox4.Text
- Dim Str25 As String = TextBox5.Text
- Dim Str26 As String = TextBox6.Text
- Dim Str27 As String = TextBox7.Text
- Dim Str28 As String = TextBox8.Text
- e.Graphics.DrawString(Str20, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(530, 770))
- e.Graphics.DrawString(Str21, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(530, 800))
- e.Graphics.DrawString(Str24, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 770))
- e.Graphics.DrawString(Str28, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 785))
- e.Graphics.DrawString(Str22, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 800))
- e.Graphics.DrawString(Str25, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 815))
- e.Graphics.DrawString(Str26, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 830))
- e.Graphics.DrawString(Str27, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 845))
- e.Graphics.DrawString(Str23, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(620, 870))
- 'RichTextBox ZuZahl Ende
- Dim Str29 As String = RichTextBox12.Text
- Dim Str30 As String = RichTextBox10.Text
- Dim Str31 As String = ComboBox20.Text
- Dim Str32 As String = ComboBox21.Text
- Dim Str33 As String = ComboBox22.Text
- Dim Str34 As String = ComboBox16.Text
- Dim Str35 As String = ComboBox7.Text
- Dim Str36 As String = ComboBox15.Text
- Dim Str37 As String = ComboBox9.Text
- e.Graphics.DrawString(Str29, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(710, 770))
- e.Graphics.DrawString(Str30, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(710, 800))
- e.Graphics.DrawString(Str32, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 770))
- e.Graphics.DrawString(Str34, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 785))
- e.Graphics.DrawString(Str31, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 800))
- e.Graphics.DrawString(Str35, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 815))
- e.Graphics.DrawString(Str37, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 830))
- e.Graphics.DrawString(Str36, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 845))
- e.Graphics.DrawString(Str33, New Font("Franklin Gothic Book", 8), Brushes.Black, New Point(635, 870))
- No19 = True
- Catch
- No19 = True
- End Try
- Try
- No20 = False
- 'Richtextbox *****
- Dim Str20 As String = ComboBox4.Text
- e.Graphics.DrawString(Str20, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(440, 915))
- 'RichTextBox ***** Ende
- No20 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No20 = True
- End Try
- Try
- No21 = False
- 'Richtextbox *****
- Dim Str21 As String = ComboBox12.Text
- Dim Str22 As String = DateTimePicker1.Text
- e.Graphics.DrawString(Str21, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(75, 962))
- e.Graphics.DrawString(Str22, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(380, 962))
- 'RichTextBox *****Ende
- No21 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No21 = True
- End Try
- Try
- 'Richtextbox *****
- No22 = False
- Dim str As String = RichTextBox14.Text
- Dim splitStr As String() = str.Split(","c)
- Dim i As Integer
- Dim String1 As String
- Dim String2 As String
- Dim String3 As String
- Dim Gesamtstring1 As String
- String1 = splitStr(0).ToString()
- String2 = splitStr(1).ToString()
- String3 = splitStr(2).ToString()
- Gesamtstring1 = splitStr(i) + Environment.NewLine + String2 + Environment.NewLine + String3
- e.Graphics.DrawString(Gesamtstring1, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(80, 1000))
- 'RichTextBox****** Ende
- No22 = True
- Catch
- MsgBox("Der Text aus dem Feld ****** konnte nicht übergeben werden")
- No22 = True
- End Try
- Try
- 'Richtextbox *****
- No23 = False
- Dim str As String = RichTextBox15.Text
- Dim splitStr As String() = str.Split(","c)
- Dim i As Integer
- Dim String1 As String
- Dim String2 As String
- Dim String3 As String
- Dim Gesamtstring1 As String
- String1 = splitStr(0).ToString()
- String2 = splitStr(1).ToString()
- String3 = splitStr(2).ToString()
- Gesamtstring1 = splitStr(i) + Environment.NewLine + String2 + Environment.NewLine + String3
- e.Graphics.DrawString(Gesamtstring1, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(320, 1000))
- 'RichTextBox ***** Ende
- No23 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No23 = True
- End Try
- Try
- 'Richtextbox *****
- No24 = False
- Dim str As String = RichTextBox16.Text
- Dim str2 As String = DateTimePicker3.Text
- Dim splitStr As String() = str.Split(","c)
- Dim i As Integer
- Dim String1 As String
- Dim String2 As String
- Dim String3 As String
- Dim Gesamtstring1 As String
- String1 = splitStr(0).ToString()
- String2 = splitStr(1).ToString()
- String3 = splitStr(2).ToString()
- Gesamtstring1 = splitStr(i) + Environment.NewLine + String2 + Environment.NewLine + String3
- e.Graphics.DrawString(Gesamtstring1, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(585, 1000))
- e.Graphics.DrawString(str2, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(690, 975))
- 'RichTextBox ***** Ende
- No24 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No24 = True
- End Try
- Try
- No25 = False
- 'Richtextbox*****
- Dim Str20 As String = ComboBox2.Text
- e.Graphics.DrawString(Str20, New Font("Franklin Gothic Book", 12), Brushes.Black, New Point(90, 1100))
- 'RichTextBox *****
- No25 = True
- Catch
- MsgBox("Der Text aus dem Feld ***** konnte nicht übergeben werden")
- No25 = True
- End Try
- ProgressBar1.Minimum = 0
- ProgressBar1.Maximum = 100
- If No1 = True Then
- ProgressBar1.Value = 4
- ProgressBar1.Update()
- End If
- If No2 = True Then
- ProgressBar1.Value = 8
- ProgressBar1.Update()
- End If
- If No3 = True Then
- ProgressBar1.Value = 12
- ProgressBar1.Update()
- End If
- If No4 = True Then
- ProgressBar1.Value = 16
- ProgressBar1.Update()
- End If
- If No5 = True Then
- ProgressBar1.Value = 20
- ProgressBar1.Update()
- End If
- If No6 = True Then
- ProgressBar1.Value = 24
- ProgressBar1.Update()
- End If
- If No7 = True Then
- ProgressBar1.Value = 28
- ProgressBar1.Update()
- End If
- If No8 = True Then
- ProgressBar1.Value = 32
- ProgressBar1.Update()
- End If
- If No9 = True Then
- ProgressBar1.Value = 36
- ProgressBar1.Update()
- End If
- If No10 = True Then
- ProgressBar1.Value = 40
- ProgressBar1.Update()
- End If
- If No11 = True Then
- ProgressBar1.Value = 44
- ProgressBar1.Update()
- End If
- If No12 = True Then
- ProgressBar1.Value = 48
- ProgressBar1.Update()
- End If
- If No13 = True Then
- ProgressBar1.Value = 52
- ProgressBar1.Update()
- End If
- If No14 = True Then
- ProgressBar1.Value = 56
- ProgressBar1.Update()
- End If
- If No15 = True Then
- ProgressBar1.Value = 60
- ProgressBar1.Update()
- End If
- If No16 = True Then
- ProgressBar1.Value = 64
- ProgressBar1.Update()
- End If
- If No17 = True Then
- ProgressBar1.Value = 68
- ProgressBar1.Update()
- End If
- If No18 = True Then
- ProgressBar1.Value = 72
- ProgressBar1.Update()
- End If
- If No19 = True Then
- ProgressBar1.Value = 76
- ProgressBar1.Update()
- End If
- If No20 = True Then
- ProgressBar1.Value = 80
- ProgressBar1.Update()
- End If
- If No21 = True Then
- ProgressBar1.Value = 84
- ProgressBar1.Update()
- End If
- If No22 = True Then
- ProgressBar1.Value = 88
- ProgressBar1.Update()
- End If
- If No23 = True Then
- ProgressBar1.Value = 92
- ProgressBar1.Update()
- End If
- If No24 = True Then
- ProgressBar1.Value = 96
- ProgressBar1.Update()
- End If
- If No25 = True Then
- ProgressBar1.Value = 100
- ProgressBar1.Update()
- End If
- If ProgressBar1.Value = 100 Then
- ProgressBar1.Value = 0
- ProgressBar1.Update()
- End If
- Label38.Text = "Stand der Datenverarbeitung:" & ProgressBar1.Value.ToString() + "%"
- Catch
- MsgBox("Fehler beim Drucken")
- End Try
- End Sub