Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Word Wrapping with Draw String

Word Wrapping with Draw String

Scheduled Pinned Locked Moved Visual Basic
questiongraphicshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chaos Machine
    wrote on last edited by
    #1

    Hello everybody. I'm trying to make the contents of a textbox, if they don't fit in a page to wrap and use the line underneath etc etc. So far i can clip the string in the given rectangle i have indicate with the setclip command. Other than that i can't make it work. Here is a part of the code: 'Create string to draw. Dim drawString As String = txtComment.Text Dim drawString1 As String = imageToLoad Dim drawFont As New Font("Arial", 0.4, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawFont1 As New Font("Arial", 0.6, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawBrush As New SolidBrush(Color.Black) ' print filename Dim drawPoint As New PointF(0.0F, -27.0F) 'print comments Dim drawPoint1 As New PointF(0.0F, 90.0F) If chkComment.Checked = True Then e.Graphics.SetClip(New Rectangle(0, 0, 100, 100)) e.Graphics.DrawString(drawString, drawFont1, drawBrush, drawPoint1) End If e.Graphics.DrawString(drawString1, drawFont, drawBrush, drawPoint) ' There are no more pages. e.HasMorePages = False The textbox in question is the txtComment.Text. Any help please? Thank you :) Still trying to find the way

    C 1 Reply Last reply
    0
    • C Chaos Machine

      Hello everybody. I'm trying to make the contents of a textbox, if they don't fit in a page to wrap and use the line underneath etc etc. So far i can clip the string in the given rectangle i have indicate with the setclip command. Other than that i can't make it work. Here is a part of the code: 'Create string to draw. Dim drawString As String = txtComment.Text Dim drawString1 As String = imageToLoad Dim drawFont As New Font("Arial", 0.4, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawFont1 As New Font("Arial", 0.6, FontStyle.Regular, GraphicsUnit.Millimeter) Dim drawBrush As New SolidBrush(Color.Black) ' print filename Dim drawPoint As New PointF(0.0F, -27.0F) 'print comments Dim drawPoint1 As New PointF(0.0F, 90.0F) If chkComment.Checked = True Then e.Graphics.SetClip(New Rectangle(0, 0, 100, 100)) e.Graphics.DrawString(drawString, drawFont1, drawBrush, drawPoint1) End If e.Graphics.DrawString(drawString1, drawFont, drawBrush, drawPoint) ' There are no more pages. e.HasMorePages = False The textbox in question is the txtComment.Text. Any help please? Thank you :) Still trying to find the way

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you use the DrawString variant that takes a Rectangle, it will wrap the string for you. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

      C 1 Reply Last reply
      0
      • C Christian Graus

        If you use the DrawString variant that takes a Rectangle, it will wrap the string for you. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

        C Offline
        C Offline
        Chaos Machine
        wrote on last edited by
        #3

        Thank you Christian. I used Dim LayoutRen As RectangleF = New RectangleF(0, 90, 100, 300) e.Graphics.DrawString(drawString, drawFont1, drawBrush, LayoutRen) and it work like a charm. Thank again! :-D Still trying to find the way

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups