Triza Khamanga Triza Khamanga - 2 months ago 6
C# Question

How can I create a button when a user click all selected text must be align on the center of rich textbox in c#

Hie, I have tried my best to create a button when a user click all selected text must be align on the center of rich textbox in c# but Am still getting what I don't want. So please can somebody help me please.

Answer

In your button's click event try this code:

    private void button1_Click(object sender, EventArgs e)
    {
    richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
    }

then you can center-align the selected part of text.

The image for the result I got (1)

The image for the result I got (2)