Etiketten A4 Blatt 3x8

  • VB.NET

Es gibt 17 Antworten in diesem Thema. Der letzte Beitrag () ist von Eddy.

    Etiketten A4 Blatt 3x8

    Guten Morgen,

    mal ne Frage, gibt es eine Möglichkeit Etiketten auf ein A4 Blatt zu drucken?

    24 Etiketten auf ein A4 Blatt, die so aussehen sollen;

    Sachnummer
    Stückzahl
    Charge WE Datum

    davon 24 Stück auf ein A4 Blatt (3x 8)

    Sachnummer, Stückzahl, Charge, WE Datum wird über die Textboxen eingetragen.

    Ich hab das so Probiert, aber ich weiß das dass totale scheiße ist.

    VB.NET-Quellcode

    1. Public Sub PrintPage1(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
    2. Dim text1 As String = TextBox1.Text & " " & TextBox1.Text & " " & TextBox1.Text
    3. Dim text2 As String = vbNewLine & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück"
    4. Dim text3 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text
    5. Dim text4 As String = vbNewLine & vbNewLine & vbNewLine & TextBox1.Text & " " & TextBox1.Text & " " & TextBox1.Text
    6. Dim text5 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück"
    7. Dim text6 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text
    8. Dim text7 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & TextBox1.Text & " " & TextBox1.Text & " " & TextBox1.Text
    9. Dim text8 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück"
    10. Dim text9 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text
    11. Dim text10 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & TextBox1.Text & " " & TextBox1.Text & " " & TextBox1.Text
    12. Dim text11 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück" & " " & TextBox2.Text & " Stück"
    13. Dim text12 As String = vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text & " " & "S/C: " & TextBox3.Text & " " & "WE: " & TextBox10.Text
    14. '-----------------------------------------------------------------------------------------------------------------
    15. Dim rect1 = e.PageBounds
    16. Dim stringFormat As New StringFormat()
    17. stringFormat.Alignment = StringAlignment.Near
    18. Using font1 As New Font("Arial", 38, FontStyle.Bold)
    19. e.Graphics.DrawString(text1, font1, Brushes.Blue, rect1, stringFormat)
    20. End Using
    21. rect1.X += 0 ' nächste Zeile
    22. Using font2 As New Font("Arial", 30, FontStyle.Regular)
    23. e.Graphics.DrawString(text2, font2, Brushes.Blue, rect1, stringFormat)
    24. End Using
    25. rect1.X += 0 ' nächste Zeile
    26. Using font3 As New Font("Arial", 15, FontStyle.Bold)
    27. e.Graphics.DrawString(text3, font3, Brushes.Blue, rect1, stringFormat)
    28. End Using
    29. rect1.X += 0 ' nächste Zeile
    30. '-----------------------------------------------------------------------------------------------------------------
    31. Using font4 As New Font("Arial", 38, FontStyle.Bold)
    32. e.Graphics.DrawString(text4, font4, Brushes.Blue, rect1, stringFormat)
    33. End Using
    34. rect1.X += 0 ' nächste Zeile
    35. Using font5 As New Font("Arial", 30, FontStyle.Regular)
    36. e.Graphics.DrawString(text5, font5, Brushes.Blue, rect1, stringFormat)
    37. End Using
    38. rect1.X += 0 ' nächste Zeile
    39. Using font6 As New Font("Arial", 15, FontStyle.Bold)
    40. e.Graphics.DrawString(text6, font6, Brushes.Blue, rect1, stringFormat)
    41. End Using
    42. rect1.X += 0 ' nächste Zeile
    43. '-----------------------------------------------------------------------------------------------------------------
    44. Using font7 As New Font("Arial", 38, FontStyle.Bold)
    45. e.Graphics.DrawString(text7, font7, Brushes.Blue, rect1, stringFormat)
    46. End Using
    47. rect1.X += 0 ' nächste Zeile
    48. Using font8 As New Font("Arial", 30, FontStyle.Regular)
    49. e.Graphics.DrawString(text8, font8, Brushes.Blue, rect1, stringFormat)
    50. End Using
    51. rect1.X += 0 ' nächste Zeile
    52. Using font9 As New Font("Arial", 15, FontStyle.Bold)
    53. e.Graphics.DrawString(text9, font9, Brushes.Blue, rect1, stringFormat)
    54. End Using
    55. rect1.X += 0 ' nächste Zeile
    56. '-----------------------------------------------------------------------------------------------------------------
    57. Using font10 As New Font("Arial", 38, FontStyle.Bold)
    58. e.Graphics.DrawString(text10, font10, Brushes.Blue, rect1, stringFormat)
    59. End Using
    60. rect1.X += 0 ' nächste Zeile
    61. Using font11 As New Font("Arial", 30, FontStyle.Regular)
    62. e.Graphics.DrawString(text11, font11, Brushes.Blue, rect1, stringFormat)
    63. End Using
    64. rect1.X += 0 ' nächste Zeile
    65. Using font12 As New Font("Arial", 15, FontStyle.Bold)
    66. e.Graphics.DrawString(text12, font12, Brushes.Blue, rect1, stringFormat)
    67. End Using
    68. rect1.X += 0 ' nächste Zeile
    69. End Sub
    Bilder
    • etikett.png

      3,16 kB, 523×84, 70 mal angesehen
    Z.B. sowas:

    VB.NET-Quellcode

    1. Private Sub DrawTextWithSpecialFormatAndColorAt(Position As Point, Text As String, FontToUse As Font, ColorToUse As Brush, StringFormat As StringFormat, e As Printing.PrintPageEventArgs)
    2. e.Graphics.DrawString(Text, FontToUse, ColorToUse, Position, StringFormat)

    Denn die Rect-Eigenschaft von e.Graphics.DrawString ist ja die Position, wo der Text hin soll.
    Wenn die zugrundeliegenden Daten dann noch in ner sinnvollen Datenstruktur sind, kannst Du den Druck sehr leicht z.B. über 2 For-Schleifen machen, eine von 1 bis 3, eine von 1 bis 8, die dann jeweils nur die Grundposition der Texte verändern und dann druckst Du jeweils Deine 4 Daten mit je einem Aufruf von DrawTextWithSpecialFormatAndColorAt, natürlich immer an leicht verschobener Stelle. Sonst wär ja alles übereinander.
    Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von „VaporiZed“, mal wieder aus Grammatikgründen.

    Aufgrund spontaner Selbsteintrübung sind all meine Glaskugeln beim Hersteller. Lasst mich daher bitte nicht den Spekulatiusbackmodus wechseln.
    @Pixxxas Ich hab mir dein restliches Problem noch nicht näher angeschaut.
    So wären deine Textverbünde wesentlich besser zu lesen.

    VB.NET-Quellcode

    1. Dim text7 As String = String.Format("{0}{0}{0}{0}{0}{0}{1} {1} {1}",Environment.newline,TextBox1.Text)
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    Sowas in etwas käme in Deine Public Sub PrintPage1(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    VB.NET-Quellcode

    1. Dim X = 0, Y = 0, k = 0
    2. For i = 1 To 8
    3. For j = 1 To 3
    4. X = j * 50
    5. Y = i * 30
    6. DrawTextWithSpecialFormatAndColorAt(New Point(X, Y), ProcessID(k), GetFontForProcessID(), GetColorForProcessID(), stringFormat, e)
    7. DrawTextWithSpecialFormatAndColorAt(New Point(X, Y + 10), ItemCount(k).ToString, GetFontForItemCount(), GetColorForItemCount(), stringFormat, e)
    8. DrawTextWithSpecialFormatAndColorAt(New Point(X, Y + 20), Batch(k), GetFontForBatch(), GetColorForBatch(), stringFormat, e)
    9. DrawTextWithSpecialFormatAndColorAt(New Point(X + 20, Y + 20), ProcessDate(k).ToShortDateString, GetFontForProcessDate(), GetColorForProcessDate(), stringFormat, e)
    10. k = k + 1
    11. Next
    12. Next

    Die ganzen Get-Funktionen sind einfache Werte-Rückgabefunktionen, damit Du dort Farben und Schriften anpassen kannst. Ggf. sinnvoll auch für die Positionsverschiebung. Batch, ItemCount, ProcessID und ProcessDate sind hier erstmal nur einfache Test-DatenArrays (String(), Integer(), Date()), die eig. in ner Klasse oder nem DataSet besser aufgehoben wären. Aber so für den Anfang sollte es reichen.
    Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von „VaporiZed“, mal wieder aus Grammatikgründen.

    Aufgrund spontaner Selbsteintrübung sind all meine Glaskugeln beim Hersteller. Lasst mich daher bitte nicht den Spekulatiusbackmodus wechseln.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „VaporiZed“ ()

    @Pixxxas Male eines in einen GraphicsPath. Den kannst Du dann nach Belieben einer Translation unterwerfen.
    Beispiele findest Du im Forum und der MSDN.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    @RodFromGermany: Guter Einwand, der sich dadurch ergibt.
    @Pixxxas: Soll 24x das gleiche Etikett gedruckt werden oder 24 unterschiedliche?
    Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von „VaporiZed“, mal wieder aus Grammatikgründen.

    Aufgrund spontaner Selbsteintrübung sind all meine Glaskugeln beim Hersteller. Lasst mich daher bitte nicht den Spekulatiusbackmodus wechseln.
    Dieses Beispiel druckt 24 gleiche Etiketten, zentiert in der Mitte des Druckbereiches.
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
    2. Dim printer As New SomeClassName
    3. Dim stuff As New Etiquette
    4. stuff.Sachnummer = "100101"
    5. stuff.Stueckzahl = "1000"
    6. stuff.charge = "000"
    7. stuff.WeDatum = Date.Now.ToShortDateString
    8. printer.PrintIt(stuff)
    9. End Sub


    VB.NET-Quellcode

    1. Imports System.Drawing.Printing
    2. Public Class SomeClassName
    3. Private Dial As New PrintPreviewDialog
    4. Private WithEvents Doc As New PrintDocument
    5. Private Data As Etiquette
    6. Public Sub PrintIt(ByVal e As Etiquette)
    7. Data = e
    8. Dial.Document = Doc
    9. Dial.ShowDialog()
    10. End Sub
    11. Private Sub PD_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Doc.PrintPage
    12. Dim width As Integer = CInt(e.MarginBounds.Width / 3)
    13. Dim height As Integer = CInt(e.MarginBounds.Height / 8)
    14. For x = 0 To 2
    15. For y = 0 To 7
    16. Dim dest As New Rectangle(x * width + e.MarginBounds.X, y * height + e.MarginBounds.Y, width, height)
    17. DrawEtiquette(e.Graphics, dest)
    18. Next
    19. Next
    20. End Sub
    21. Private Sub DrawEtiquette(ByVal g As Graphics, ByVal rect As Rectangle)
    22. Using SF As New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center}
    23. Using f30 As New Font("Arial", 30, FontStyle.Regular)
    24. Using f20 As New Font("Arial", 20, FontStyle.Regular)
    25. Using f10 As New Font("Arial", 10, FontStyle.Regular)
    26. Dim r1 As New Rectangle(rect.X, rect.Y, rect.Width, CInt(rect.Height / 3))
    27. Dim r2 As New Rectangle(rect.X, rect.Y + r1.Height, rect.Width, CInt(rect.Height / 3))
    28. Dim r3 As New Rectangle(rect.X, rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    29. Dim r4 As New Rectangle(rect.X + CInt(rect.Width / 2), rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    30. g.DrawString(Data.Sachnummer, f30, Brushes.Black, r1, SF)
    31. g.DrawString(Data.Stueckzahl, f20, Brushes.Black, r2, SF)
    32. g.DrawString(Data.charge, f10, Brushes.Black, r3, SF)
    33. g.DrawString(Data.WeDatum, f10, Brushes.Black, r4, SF)
    34. g.DrawRectangle(Pens.Black, rect)
    35. End Using
    36. End Using
    37. End Using
    38. End Using
    39. End Sub
    40. End Class
    41. Public Structure Etiquette
    42. Dim Sachnummer As String
    43. Dim Stueckzahl As String
    44. Dim charge As String
    45. Dim WeDatum As String
    46. End Structure
    And i think to myself... what a wonderfuL World!

    Pixxxas schrieb:

    Aber wie mache ich, das er gleich druckt ohne erst die Vorschau anzuzeigen?


    Indem du einfach den PrintPreviewDialog weg laesst.
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Imports System.Drawing.Printing
    2. Public Class SomeClassName
    3. Private WithEvents Doc As New PrintDocument
    4. Private Data As Etiquette
    5. Public Sub PrintIt(ByVal e As Etiquette)
    6. Data = e
    7. Doc.Print()
    8. End Sub
    9. Private Sub Doc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Doc.PrintPage
    10. Dim width As Integer = CInt(e.MarginBounds.Width / 3)
    11. Dim height As Integer = CInt(e.MarginBounds.Height / 8)
    12. For x = 0 To 2
    13. For y = 0 To 7
    14. Dim dest As New Rectangle(x * width + e.MarginBounds.X, y * height + e.MarginBounds.Y, width, height)
    15. DrawEtiquette(e.Graphics, dest)
    16. Next
    17. Next
    18. End Sub
    19. Private Sub DrawEtiquette(ByVal g As Graphics, ByVal rect As Rectangle)
    20. Using SF As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
    21. Using f30 As New Font("Arial", 30, FontStyle.Regular)
    22. Using f20 As New Font("Arial", 20, FontStyle.Regular)
    23. Using f10 As New Font("Arial", 10, FontStyle.Regular)
    24. Dim r1 As New Rectangle(rect.X, rect.Y, rect.Width, CInt(rect.Height / 3))
    25. Dim r2 As New Rectangle(rect.X, rect.Y + r1.Height, rect.Width, CInt(rect.Height / 3))
    26. Dim r3 As New Rectangle(rect.X, rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    27. Dim r4 As New Rectangle(rect.X + CInt(rect.Width / 2), rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    28. g.DrawString(Data.Sachnummer, f30, Brushes.Black, r1, SF)
    29. g.DrawString(Data.Stueckzahl, f20, Brushes.Black, r2, SF)
    30. g.DrawString(Data.charge, f10, Brushes.Black, r3, SF)
    31. g.DrawString(Data.WeDatum, f10, Brushes.Black, r4, SF)
    32. g.DrawRectangle(Pens.Black, rect)
    33. End Using
    34. End Using
    35. End Using
    36. End Using
    37. End Sub
    38. End Class
    39. Public Structure Etiquette
    40. Dim Sachnummer As String
    41. Dim Stueckzahl As String
    42. Dim charge As String
    43. Dim WeDatum As String
    44. End Structure
    And i think to myself... what a wonderfuL World!
    @Pixxxas Gib der Vorlage einen variablen Rand für x und für y.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Du koenntest anstatt e.MarginBounds e.PageBounds im Doc.PrintPage nutzen, wobei du so in den nicht bedruckbaren Bereich kommen kannst. Du kannst allerdings auch selbst, wie RodFromGermany bereits sagte einen Bereich definieren.

    So koennte das aussehen, hier auch mit ein wenig Platz zwischen den Etiketten.

    Spoiler anzeigen

    VB.NET-Quellcode

    1. Private Sub PD_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Doc.PrintPage
    2. Dim fullRect As New Rectangle(e.PageBounds.X, e.PageBounds.Y, e.PageBounds.Width, e.PageBounds.Height)
    3. Dim space As Integer = 5
    4. Dim rowCount As Integer = 8
    5. Dim colCount As Integer = 3
    6. Dim width As Integer = CInt(fullRect.Width / colCount)
    7. Dim height As Integer = CInt(fullRect.Height / rowCount)
    8. For x = 0 To colCount - 1
    9. For y = 0 To rowCount - 1
    10. Dim dest As New Rectangle(x * width + x * space + fullRect.X, y * height + y * space + fullRect.Y, width - (colCount - 1) * space, height - (rowCount - 1) * space)
    11. DrawEtiquette(e.Graphics, dest)
    12. Next
    13. Next
    14. End Sub
    And i think to myself... what a wonderfuL World!

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Eddy“ ()

    @Pixxxas
    Nimm diesen Code, hatte oben einen kleinen Fehler drin, so stimmen die abstaende zwischen den Etiketten.

    VB.NET-Quellcode

    1. Private Sub PD_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Doc.PrintPage
    2. Dim outerSpace As Integer = 20
    3. Dim innerSpace As Integer = 5
    4. Dim rowCount As Integer = 8
    5. Dim colCount As Integer = 3
    6. Dim fullRect As New Rectangle(e.PageBounds.X + outerSpace, e.PageBounds.Y + outerSpace, e.PageBounds.Width - 2 * outerSpace, e.PageBounds.Height - 2 * outerSpace)
    7. Dim width As Integer = CInt((fullRect.Width - colCount * innerSpace) / colCount)
    8. Dim height As Integer = CInt((fullRect.Height - rowCount * innerSpace) / rowCount)
    9. For x = 0 To colCount - 1
    10. For y = 0 To rowCount - 1
    11. Dim dest As New Rectangle(x * width + x * innerSpace + fullRect.X, y * height + y * innerSpace + fullRect.Y, width, height)
    12. DrawEtiquette(e.Graphics, dest)
    13. Next
    14. Next
    15. End Sub



    Pixxxas schrieb:

    so das Charge und WE direkt unter der Stückzahl steht?


    Du kannst anstatt diese Ueberladung
    .DrawString(String, Font, Brush, Rectangle, StringFormat)
    diese nutzen:
    .DrawString(String, Font, Brush, Integer, Integer)

    Also einen Point zur Positionsangabe. Beispiel mit beiden Ueberladungen:

    VB.NET-Quellcode

    1. Private Sub DrawEtiquette(ByVal g As Graphics, ByVal rect As Rectangle)
    2. Using SF As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
    3. Using f30 As New Font("Arial", 30, FontStyle.Regular)
    4. Using f20 As New Font("Arial", 20, FontStyle.Regular)
    5. Using f10 As New Font("Arial", 10, FontStyle.Regular)
    6. Dim r1 As New Rectangle(rect.X, rect.Y, rect.Width, CInt(rect.Height / 3))
    7. Dim r2 As New Rectangle(rect.X, rect.Y + r1.Height, rect.Width, CInt(rect.Height / 3))
    8. Dim r3 As New Rectangle(rect.X, rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    9. Dim r4 As New Rectangle(rect.X + CInt(rect.Width / 2), rect.Y + r1.Height + r2.Height, CInt(rect.Width / 2), CInt(rect.Height / 3))
    10. g.DrawString(Data.Sachnummer, f30, Brushes.Black, r1, SF)
    11. g.DrawString(Data.Stueckzahl, f20, Brushes.Black, r2, SF)
    12. g.DrawString(Data.charge, f10, Brushes.Black, r3.X, r3.Y)
    13. g.DrawString(Data.WeDatum, f10, Brushes.Black, r4.X, r4.Y)
    14. g.DrawRectangle(Pens.Black, rect)
    15. End Using
    16. End Using
    17. End Using
    18. End Using
    19. End Sub


    Also anstatt Rectangles(r1 - r4) kannst du auch direkt Punkte festlegen wo der Text gezeichnet werden soll, wichtig ist dabei nur, das du dich an den koordinaten des uebergebenen Rectangles(rect) orientierst. Also z.B. rect.x + 3, rect.y +3....
    And i think to myself... what a wonderfuL World!

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Eddy“ ()

    @Eddy Ich hab mir mal erlaubt, Deinen DrawEtiquette-Code etwas zu optimieren:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Private f30 As New Font("Arial", 30, FontStyle.Regular)
    2. Private f20 As New Font("Arial", 20, FontStyle.Regular)
    3. Private f10 As New Font("Arial", 10, FontStyle.Regular)
    4. Private Sub DrawEtiquette(ByVal g As Graphics, ByVal rect As Rectangle, data As Daten)
    5. Using SF As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
    6. Dim r1 As New Rectangle(rect.X, rect.Y, rect.Width, rect.Height \ 3)
    7. Dim r2 As New Rectangle(rect.X, rect.Y + r1.Height, rect.Width, rect.Height \ 3)
    8. Dim r3 As New Rectangle(rect.X, rect.Y + r1.Height + r2.Height, rect.Width \ 2, rect.Height \ 3)
    9. Dim r4 As New Rectangle(rect.X + rect.Width \ 2, rect.Y + r1.Height + r2.Height, rect.Width \ 2, rect.Height \ 3)
    10. g.DrawString(data.Sachnummer, f30, Brushes.Black, r1, SF)
    11. g.DrawString(data.Stueckzahl, f20, Brushes.Black, r2, SF)
    12. g.DrawString(data.charge, f10, Brushes.Black, r3.X, r3.Y)
    13. g.DrawString(data.WeDatum, f10, Brushes.Black, r4.X, r4.Y)
    14. g.DrawRectangle(Pens.Black, rect)
    15. End Using
    16. End Sub
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!