Control.RightToLeft Control.RightToLeft Control.RightToLeft Control.RightToLeft Property

定义

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

public:
 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 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父级Form相同。For example, a Button will have the same BackColor as its parent Form by default. 有关环境属性的详细信息,请参阅AmbientPropertiesControl或类概述。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.Yes影响:The 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).

  • 水平滚动条从滚动框(滚动块)右对齐开始。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.

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

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

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

适用于

另请参阅