locked
Paragraph formatting and line spacing C# RRS feed

  • Question

  •  

    Hi,

    I am working on C# and windows application(.NET 2003 and framework 1.1)

    I have 2 queries :

    1. I am working on achieving "Justify"(similar to the one which is available in MS word). Could anyone let me know how this can be done? I am not able to find any material or any inbuilt function on internet.
    2. I am working on another concept of "Line Spacing"(similar to one in MS word). Please can anyone let me know how to achieve this too???

    If you could give me the logic, i think i should be able to achieve this.

    Thanks and Regards,
    Sudarshan

    Monday, September 22, 2008 8:44 AM

Answers

  • Hi,

    I am drawing using DrawString function. Can you please send me a code snippet???

    Thanks
    Sudhi
    Thursday, September 25, 2008 4:08 AM

All replies

  • How are you drawing this text?  If you are using gdi+ you can just increment the y in the point as you are drawing lines to handle line spacing.  For justify use the overloaded Graphics.DrawString that takes the StringFormat object and use the StringFormat object's LineAlignment property. 

    An RTF box has a SelectionAlignment property that you could also use.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectionalignment.aspx


    Here is an article where someone extends the richtextbox .  Do a search in comments for PFM_LINESPACING and you should see the code for setting linespacing in rtf box.
    http://geekswithblogs.net/pvidler/archive/2003/10/15/182.aspx
    • Marked as answer by jack 321 Thursday, September 25, 2008 3:58 AM
    • Unmarked as answer by Sudarshan Belur Thursday, September 25, 2008 4:08 AM
    Tuesday, September 23, 2008 3:41 AM
  • Hi,

    I am drawing using DrawString function. Can you please send me a code snippet???

    Thanks
    Sudhi
    Thursday, September 25, 2008 4:08 AM
  • Hi,

    I am drawing using DrawString function. Can you please send me a code snippet???

    Thanks
    Sudhi
    Thursday, September 25, 2008 4:08 AM