chrs
chrs

Reputation: 6096

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.

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

Upvotes: 0

Views: 724

Answers (1)

user584316
user584316

Reputation:

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

Upvotes: 1

Related Questions