Mixed LTR and RTL text in a TextBox control
I have a plain TextBox control in my WinForm application, and I type a string with mixed English and Farsi t开发者_开发技巧ext (mix of LTR and RTL). When the TextBox RightToLeft property is set to Yes, it works fine on UI as expected, but when I get the Text property of the TextBox, the string is not what the control shows, and is completely different/wrong.
Here's a screenshot of how the text looks inside the Textbox control (right) and what the Text property returns (shown in a MessageBox).
How can I fix this? I expect Text property to return the same thing that is displayed on the UI.
You could pass MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign
to the options
argument of MessageBox.Show
to have the message box both align its text right and also render the entire message box with its text right-to-left:
MessageBox.Show("تست English-mixed جمله ...",
"عنوان Title",
MessageBoxButtons.OK,
MessageBoxIcon.None,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
Result:
精彩评论