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 将具有与其父 Form 相同的 BackColorFor 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.Yes RightToLeft 属性值的影响:The following are a few examples of how control elements are affected by the RightToLeft property value of RightToLeft.Yes :

  • 垂直滚动条显示在滚动控件(例如 FormPanel、多行 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).

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

  • 对于 CheckBoxRadioButton 控件,将反转由 CheckAlign 属性控制的复选框元素对齐方式。The 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.

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

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

  • RightToLeft 属性不影响 ToolBar 控件上的工具栏按钮或 ToolBarButton 上的文本对齐方式。The 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. 不需要重写 RightToLeft 属性的 getset 访问器;如果需要,只能重写一个。You are not required to override both the get and set accessors of the RightToLeft property; you can override only one if needed.