Control.RightToLeft 属性


获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

 virtual property System::Windows::Forms::RightToLeft RightToLeft { System::Windows::Forms::RightToLeft get(); void set(System::Windows::Forms::RightToLeft value); };
public virtual System.Windows.Forms.RightToLeft RightToLeft { get; set; }
member this.RightToLeft : System.Windows.Forms.RightToLeft with get, set
Public Overridable Property RightToLeft As RightToLeft



RightToLeft 值之一。One of the RightToLeft values. 默认值为 InheritThe default is Inherit.


分配的值不是 RightToLeft 值之一。The assigned value is not one of the RightToLeft values.


RightToLeft属性为环境属性。The RightToLeft property is an ambient property. 环境属性是一个控件属性,如果未设置,则将从父控件中检索该属性。An ambient property is a control property that, if not set, is retrieved from the parent control. 例如, Button BackColor 默认情况下,将与其父级相同 FormFor example, a Button will have the same BackColor as its parent Form by default. 有关环境属性的详细信息,请参阅 AmbientProperties 类或 Control 类概述。For more information about ambient properties, see the AmbientProperties class or the Control class overview.

RightToLeft 属性用于从右到左书写语言(例如希伯来语或阿拉伯语)的国际化应用程序。The RightToLeft property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. 如果将此属性设置为 RightToLeft.Yes ,则将从右到左显示包含文本的控件元素。When this property is set to RightToLeft.Yes, control elements that include text are displayed from right to left.


如果在 RightToLeft 运行时更改属性的值,则只保留未设置格式的原始文本。If the value of the RightToLeft property is changed at run time, only raw text without formatting is preserved.

下面是一些示例,说明控件元素如何受 RightToLeft 属性值的影响 RightToLeft.YesThe following are a few examples of how control elements are affected by the RightToLeft property value of RightToLeft.Yes :

  • 垂直滚动条显示在左侧,而不是显示在可滚动控件的右边 (例如,、、 Form Panel 多行 TextBoxRichTextBox) 。Vertical scroll bars are displayed on the left side rather than right side of scrollable controls (for example, Form, Panel, multiline TextBox, and RichTextBox).

  • 水平滚动条从滚动框开始 (thumb) 右对齐。Horizontal scroll bars start with the scroll box (thumb) right-aligned.

  • CheckAlign对于和控件,将反转复选框元素对齐方式,由属性 CheckBox 控制 RadioButtonThe check box element alignment, controlled by the CheckAlign property, is reversed for CheckBox and RadioButton controls.

  • 列表框、组合框和 up-down 控件中的项将右对齐。Items in list box, combo box, and up-down controls are right aligned.

  • "上移" 和 "下移" 按钮在和控件上左对齐 NumericUpDown DomainUpDownUp and down buttons are left-aligned on NumericUpDown and DomainUpDown controls.

  • (MainMenuMenuItemContextMenu) 的菜单显示为右对齐。Menus (MainMenu, MenuItem, and ContextMenu) are displayed right-aligned.

  • 控件上的工具栏按钮 ToolBar 或上的文本对齐方式 ToolBarButton 不受属性的影响 RightToLeftThe alignment of toolbar buttons on a ToolBar control or the alignment of text on a ToolBarButton is not affected by the RightToLeft property.

  • AxHost 支持从右到左对齐;但是,对 ActiveX 控件的影响取决于控件作者为从右到左显示而实现的支持程度。AxHost supports right-to-left alignment; however, the effect on an ActiveX control depends on the extent to which the control author implemented support for right-to-left display.


当在 RightToLeft 派生类中重写属性时,使用基类的 RightToLeft 属性扩展基实现。When overriding the RightToLeft property in a derived class, use the base class's RightToLeft property to extend the base implementation. 否则,必须提供所有实现。Otherwise, you must provide all the implementation. 不需要重写 get 属性的和 set 访问器 RightToLeft ; 如果需要,只能重写一个。You are not required to override both the get and set accessors of the RightToLeft property; you can override only one if needed.