render right to left text in csharp

To render right-to-left text in C#, you can set the RightToLeft property of the control to true. This will align the text from right to left.

main.cs
textBox.RightToLeft = RightToLeft.Yes; // for textbox
label.RightToLeft = RightToLeft.Yes; // for label
104 chars
3 lines

If you're working with unicode strings, you can set the Direction property of the string to RightToLeft. This will render the string from right to left, even if it contains left-to-right characters.

main.cs
string myText = "مرحبا بالعالم"; //text in arabic language
myText = new string(myText.ToCharArray().Reverse().ToArray()); // reverse the string
myText = string.Format("{0}{1}", myText, (char)0x200F); // add RLE character to force RTL rendering
myLabel.Text = myText; // set the text
283 chars
5 lines

gistlibby LogSnag