This is a migrated thread and some comments may be shown as answers.

Determining Line Spacing at Caret Position

1 Answer 116 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 08 Feb 2013, 10:54 PM
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.

NEVERMIND... I GOT IT!

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 13 Feb 2013, 07:58 AM
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:
box.ChangeParagraphLineSpacing(1);
box.ChangeParagraphSpacingAfter(0);

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

Regards,
Jack
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Ken
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or