Udostępnij za pośrednictwem


How to: Display Right-to-Left Text in Windows Forms for Globalization

Certain scripts, such as Arabic, are written from right to left. To control the flow of text in a control such as a TextBox, you use the RightToLeft property. An additional step is needed, however, to mirror the control itself on the form: You must set the RightToLeftLayout property, which controls the appearance of controls within a container.

You do not need to change the values of properties such as the TextAlign value of a TextBox control: the value stays the same but the alignment is reversed.

To display right-to-left text

  1. Set the form's RightToLeft property to Yes.

  2. Set the form's RightToLeftLayout property to true.

  3. Place a TextBox control on the form, either programmatically or using a development environment such as Visual Studio. It will inherit the right-to-left setting of the form, since the default value for the RightToLeft property is Inherit. (If you wish to override the setting for another control on the form, set that control's RightToLeft property to No.)

  4. Compile and run your application. You will notice that the form's controls and title are mirrored to run from right to left. Enter text inside of the TextBox. You will notice that it enters from right to left.

See Also

Reference

RightToLeft

RightToLeft

Other Resources

Globalizing and Localizing Applications