With
System.Windows.Forms.RichTextBox
, append to the
Rtf
code:
string.Format("\qr {0}\par\", yourParagraphText);
your text in the variable
yourParagraphText
will be appended as right-aligned. Or use another property,
SelectedRtf
, to insert in the middle.
Yes, stupid RTF coding, I know. I did it typing two paragraphs in WordPad, saving the file and looking at what's inside.
Without RTF row code, use the property
System.Windows.Forms.RichTextBox.SelectionAlignment
with a preliminary selected paragraph. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectionalignment.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.horizontalalignment.aspx[
^].
This was not nice of you not to indicate if you work with Forms or WPF. Now about WPF:
As to
System.Windows.Controls.RichTextBox
, you should do all the work with
FlowDocument
instead, and get a
RichTextBox
using the constructor
RichTextBox(FlowDocument document)
, please see:
http://msdn.microsoft.com/en-us/library/ms597536.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.documents.flowdocument.aspx[
^].
—SA