简体   繁体   English

富文本框的居中部分

[英]Centering Parts of rich text boxes

So I wanna center the selected text in a richtextbox, but when i use this code it centers all the text after aswell. 因此,我想在Richtextbox中居中显示所选文本,但是当我使用此代码时,它将所有文本居中对齐。

public static void ChangeSelectedTextAlignment(RichTextBox control)
        {
            control.SelectionAlignment = HorizontalAlignment.Center;
}

How can I do so it is only the selected text which is centered. 我该怎么做,只是所选文本居中。 Just like word etc 就像单词等

The alignment property doesn't work selection wise. 对齐属性不适用于明智的选择。 It works paragraph wise, where the cursor appears in case a paragraph is not already selected. 它适用于段落操作,如果尚未选择段落,则会出现光标。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM