How to edit line spacing and character spacing on richtextbox in winform? I’ve tried PARAFORMAT2 but it does not allow deep setting. I want to set spacing like photoshop. For example;
In the picture is three different spacing format. How to set spacing like 1,2,3 in the picture?
2
Answers
Line Spacing
You can send
EM_SETPARAFORMAT
message to the rich text box control and passPARAFORMAT2
aslparam
. To control line spacing, you should set thePFM_LINESPACING
flag in thedwMask
member and setbLineSpacingRule
anddyLineSpacing
members ofPARAFORMAT2
to suitable values based on your requirements.Since you need fine-tuning for line spacing, it seems 4 is suitable for
bLineSpacingRule
and then you can setdyLineSpacing
to any value in twip unit. For more information about available options forbLineSpacingRule
, readPARAFORMAT2
documentations.Character Spacing
Based on documentation of
sSpacing
inCHARFORMAT2
, setting character spacing has no effect on the text displayed by a rich edit control.Code
Here linespaces are lower than 0. You can adjust de "sl-" parameter, by example "sl-440", the FontFamily, the "em-size" in pts (14), and other text parameters. You can also, evidently, complete the rtf code, but the RichTextBox should do it for you.