Center text in a RichTextBox

csharp United States
  • 18 years ago

    Can anyone tell me how to center selected text in a RichTextBox. I loaded a rtf formatted document from Word that was centered in Word and it displayed centered in the RichTextBox so I think it can be done. I would apprectiate any help. Thanks,


    Kyle

  • 18 years ago

    Hmm, try using the SelectedAlign method if there is such a thing. I think you have to use a SelectedSomethingOrOther method to achieve this.

  • 18 years ago

    Louis,


    I found the answer.


    richTextBox1.SelectionAlignment = HorizontalAlignment.Center;


    Thanks for your input!


    Regards,


    Kyle

  • 18 years ago

    ahh thanks, I thought it was something like that!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne