Dev Center > Windows Forms Forums > Windows Forms General > Detecting wordwrap and padding accordingly? (RichTextbox?)

Answered Detecting wordwrap and padding accordingly? (RichTextbox?)

  • Monday, February 15, 2010 3:12 PM
     
     
    Heya,

    I'm trying to format a chat field something like this:

      12. july, 2010
    
        12:40 Hi, are you there now?
    
        12:46 Cool, cya tonight :-) What do you want me to bring?
    
        01:16 Sure thing, it's all packed and ready!
    
    

    Looks pretty fine and is easy to do. Now, my problem is if the text is too long (or the window too small), it could look like this:

      12. july, 2010
    
        12:40 Hi, are you there now?
    
        12:46 Cool, cya tonight :-) What do you want me to 
    
    bring?
    
        01:04 No, i cannot bring the alligator, it is just 
    
    too dangerous - it would probably kill us all before we 
    
    even got the party started! ;-)
    
    

    That's exactly my problem (not the alligator, the word wrap!). I'd like it to wrap like this:

      12. july, 2010
    
        12:40 Hi, are you there now?
    
        12:46 Cool, cya tonight :-) What do you want me to 
    
              bring?
    
        01:04 No, i cannot bring the alligator, it is just 
    
              too dangerous - it would probably kill us all 
    
              before we even got the party started! ;-)
    
    

    How would i do that? Using a RichTextbox, or something else?

    Thanks for any help - this is the last piece of my apps puzzle that needs to be solved :-)

    // Yoc.
    • Edited by Yocal Monday, February 15, 2010 3:13 PM Layout
    •  

Answers

  • Monday, February 15, 2010 10:26 PM
     
     Answered
    hi,


    EDIT: Sorry, I set you of in the wrong direction  ...  just set SelectionHangingIndent and SelectionIndent before you add text.


    //the simplest way i can think of is to use rtf directly and set fi and li tags on your paragraphs.
    //
    //You can see some samples on how to control paragraph indentation and justification here (pages 14- 21) and here, or just google it :)

    Hope this helps ...

    best regards,
    Vladimir
    • Edited by Vladimir.Ilic Tuesday, February 16, 2010 6:51 PM SelectionIndent & SelectionHangingIndent properties
    • Marked As Answer by Aland LiModerator Thursday, February 18, 2010 11:02 AM
    •