Determining Line Spacing at Caret Position

2 posts, 0 answers
  1. Ken
    Ken avatar
    5 posts
    Member since:
    Jan 2013

    Posted 08 Feb 2013 Link to this post

    When creating or editing a document using the RadRichTextBox control, I've allowed the user to change the line spacing and spacing before and after a paragraph.  The user can then select one or more paragraphs and change these settings, which only apply to the selected area.

    How can I determine at runtime what the line/paragraph spacing is for the paragraph at the current caret position?

    Any help is greatly appreciated.

  2. Jack
    Jack avatar
    2333 posts

    Posted 13 Feb 2013 Link to this post

    Hello Ken,

    I am glad to hear that you have found a solution. I will post my suggestion here, so the community can benefit from it.

    You can do this by accessing the paragraph that is currently pointed at the caret position. Here is a sample:
    Paragraph paragraph = box.Document.CaretPosition.GetCurrentParagraphBox().AssociatedParagraph;
    double lineSpacing = paragraph.LineSpacing;
    float spacingAfter = paragraph.SpacingAfter;

    Later you can modify these settings by using the appropriate methods of RadRichTextBox:

    If you have other questions, do not hesitate to write us.

    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top