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. C#
  4. Textbox text scrunched

Textbox text scrunched

Scheduled Pinned Locked Moved C#
comhelptutorial
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.
  • L Offline
    L Offline
    LimitedAtonement
    wrote on last edited by
    #1

    Dear Sirs, I'm using a textbox control to display some text and the text on the right is appearing scrunched. It looks as though it displays the first x distance (I'm pretty sure it looks to be measured in distance, not characters) normally, and then squishes the characters (horizontally) taking out all character spacing so that they're not overlapping, but touching. Perhaps I'll give you a picture...I can't see how to insert one into the post, so I'll give you a link to my SkiDrive. My sky-drive photo. As you can see from the photo, the text is scrunched on one row, but not two rows down!! If you can tell me how to fix this, let me know. THANKS!!

    In Christ, Aaron Laws http://ProCure.com

    E 1 Reply Last reply
    0
    • L LimitedAtonement

      Dear Sirs, I'm using a textbox control to display some text and the text on the right is appearing scrunched. It looks as though it displays the first x distance (I'm pretty sure it looks to be measured in distance, not characters) normally, and then squishes the characters (horizontally) taking out all character spacing so that they're not overlapping, but touching. Perhaps I'll give you a picture...I can't see how to insert one into the post, so I'll give you a link to my SkiDrive. My sky-drive photo. As you can see from the photo, the text is scrunched on one row, but not two rows down!! If you can tell me how to fix this, let me know. THANKS!!

      In Christ, Aaron Laws http://ProCure.com

      E Offline
      E Offline
      ely_bob
      wrote on last edited by
      #2

      one of three three things: If you are "creating your own" text box.. I really recomend against it.. use the Rich text or normal text box... but if you are you are using GDI+ to do the drawing in which case you should be using Graphics.DrawString()... not cycling threw your characters.. this looks like what the problem is.. remember that if your want to use this approach that you will need to add in the letter padding manually (X+=3;). Now if that is not the case: You may have inadvertently set a flag somewhere for your first string and then re initialized(clearing the flag) for the subsequent strings. Lastly if you are using different fonts, or units of measure you may get a squinched string... But you could post some code.. that might help.

      L 1 Reply Last reply
      0
      • E ely_bob

        one of three three things: If you are "creating your own" text box.. I really recomend against it.. use the Rich text or normal text box... but if you are you are using GDI+ to do the drawing in which case you should be using Graphics.DrawString()... not cycling threw your characters.. this looks like what the problem is.. remember that if your want to use this approach that you will need to add in the letter padding manually (X+=3;). Now if that is not the case: You may have inadvertently set a flag somewhere for your first string and then re initialized(clearing the flag) for the subsequent strings. Lastly if you are using different fonts, or units of measure you may get a squinched string... But you could post some code.. that might help.

        L Offline
        L Offline
        LimitedAtonement
        wrote on last edited by
        #3

        Dear Mr. ely_bob, Thanks for your response! You know what...now that you mention it, It might be using GDI+ that the text is being drawn. I just realized that the TextBox control is used for EDITING the value, not displaying it! I keep forgetting that it's programmed that way. I'll look at it. So you think that maybe what's happenning is that the x += 2; is not persisting; okay, I'll check it out. Thanks again.

        [====EDIT====]

        It looks like this is the code used to draw the strings:

        context.Graphics.DrawString(label, _font, _brush, clipRect, _format);

        Yup...just checked, and I see where it drew my string. So...let's see. the arguments

        label = "0.0\0.0\-25.0\0.0\0.0\-25.0\0.0\0.0\-25.0\0.0\0.0\-25.0\0.0\0.0\-25.0 "
        _font = {[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False]}
        _brush = {System.Drawing.SolidBrush}
        clipRect = {X=418,Y=768,Width=338,Height=16}
        _format = {[StringFormat, FormatFlags=FitBlackBox, NoWrap, NoClip]}

        Now, I'm reading about the format.FitBlackBox property, it says "...By default, characters are repositioned to avoid any overhang." I would guess that this is the effect I'm complaining about, but after changing that, I still have the effect. Let me know what you think.

        In Christ, Aaron Laws http://ProCure.com

        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