Export (0) Print
Expand All

MainMenu.RightToLeft Property

Gets or sets whether the text displayed by the control is displayed from right to left.

[Visual Basic]
Public Overridable Property RightToLeft As RightToLeft
[C#]
public virtual RightToLeft RightToLeft {get; set;}
[C++]
public: __property virtual RightToLeft get_RightToLeft();
public: __property virtual void set_RightToLeft(RightToLeft);
[JScript]
public function get RightToLeft() : RightToLeft;
public function set RightToLeft(RightToLeft);

Property Value

One of the RightToLeft values.

Exceptions

Exception Type Condition
InvalidEnumArgumentException The value assigned to the property is not a valid member of the RightToLeft enumeration.

Remarks

This property allows your menus to support languages that are written from right to left. When this property is set to RightToLeft.Yes, the menu item text will be displayed from right to left instead of the default left to right method.

Note   For more information about how enabling right-to-left alignment affects Windows Forms controls, see the RightToLeft property.

Example

[Visual Basic, C#, C++] The following example uses the GetForm method to determine if a MainMenu is currently parented to the form. If the call in the example code to GetForm does not return a null, the code then clones the menu structure of the MainMenu using the CloneMenu method. The example code then sets the RightToLeft property to RightToLeft.Yes on the new copy of the MainMenu to create a MainMenu that can be used for languages that support right to left text. This example assumes that you have a MainMenu created that is named mainMenu1.

[Visual Basic] 
Public Sub CloneMyMenu()
    ' Determine if mainMenu1 is currently hosted on the form.
    If Not (mainMenu1.GetForm() Is 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


[C#] 
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;
   }
}


[C++] 
public:
 void CloneMyMenu()
 {
    // Determine if mainMenu1 is currently hosted on the form.
    if(mainMenu1->GetForm() != 0)
    {
       // 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;
    }
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MainMenu Class | MainMenu Members | System.Windows.Forms Namespace | RightToLeft

Show:
© 2014 Microsoft