通过


MainMenu.RightToLeft 属性

定义

获取或设置控件显示的文本是否从右向左显示。

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

示例

下面的代码示例使用 GetForm 该方法来确定当前是否 MainMenu 为窗体添加父级。 如果示例代码GetForm中的调用不返回null,则代码将克隆使用CloneMenu该方法的MainMenu菜单结构。 然后,示例代码将 RightToLeft 属性设置为 RightToLeft.Yes 在新副本 MainMenu 上创建一个 MainMenu 可用于支持从右到左文本的语言。 此示例要求你已创建名为 /a0> 的创建 项。

void CloneMyMenu()
{
   // Determine if mainMenu1 is currently hosted on the form.
   if ( mainMenu1->GetForm() != nullptr )
   {
      // Create a copy of the MainMenu that is hosted on the form.
      MainMenu^ mainMenu2 = mainMenu1->CloneMenu();

      // Set the RightToLeft property for mainMenu2.
      mainMenu2->RightToLeft = ::RightToLeft::Yes;
   }
}
public void CloneMyMenu()
{
   // Determine if mainMenu1 is currently hosted on the form.
   if(mainMenu1.GetForm() != null)
   {
      // Create a copy of the MainMenu that is hosted on the form.
      MainMenu mainMenu2 = mainMenu1.CloneMenu();
      // Set the RightToLeft property for mainMenu2.
      mainMenu2.RightToLeft = RightToLeft.Yes;
   }
}
Public Sub CloneMyMenu()
    ' Determine if mainMenu1 is currently hosted on the form.
    If (mainMenu1.GetForm() IsNot Nothing) Then
        ' Create a copy of the MainMenu that is hosted on the form.
        Dim mainMenu2 As MainMenu = mainMenu1.CloneMenu()
        ' Set the RightToLeft property for mainMenu2.
        mainMenu2.RightToLeft = RightToLeft.Yes
    End If
End Sub

注解

此属性使菜单能够支持从右到左写入的语言。 如果此属性设置为 RightToLeft.Yes,菜单项文本将从右向左显示,而不是默认的从左到右方法。

注释

有关启用从右到左对齐如何影响 Windows 窗体控件的详细信息,请参阅该 RightToLeft 属性。

适用于

另请参阅