Control.RightToLeft 屬性

定義

取得或設定值,指出控制項的項目是否對齊,以支援使用由右至左字型的地區設定。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

其中一個 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.YesRightToLeft 屬性值影響的範例: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).

  • 水準捲軸會以靠右對齊的捲動方塊(thumb)開頭。Horizontal scroll bars start with the scroll box (thumb) right-aligned.

  • 核取方塊專案對齊(由 CheckAlign 屬性控制)會針對 CheckBoxRadioButton 控制項反轉。The check box element alignment, controlled by the CheckAlign property, is reversed for CheckBox and RadioButton controls.

  • 清單方塊、下拉式方塊和上下按鈕控制項中的專案會靠右對齊。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.

  • 功能表([MainMenu]、[MenuItem] 和 [ContextMenu])會靠右對齊顯示。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. 您不需要覆寫 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.

適用於

另請參閱