Udostępnij za pośrednictwem


How to: Create Message Boxes for Bi-Directional Windows Forms

By default, a message box appears to users with left-to-right reading order. You can create messages boxes with right-to-left reading order and mirroring by passing certain parameters when you display the message box.

To create bi-directional message boxes

  • Call the MessageBox class's Show method, and in the options parameter, pass the logical OR combination of the RtlReading and RightAlign members of the MessageBoxOptions enumeration.

    The RightAlign member ensures that wrapped text is aligned properly.

    Note

    The captions of buttons on the message box, such as OK, are established by the Windows operating system locale, and you cannot set these during the call.

    The following code example shows how to display a message box with right-to-left reading order and mirroring:

    ' Visual Basic
    MessageBox.Show("Text", "Caption", _
       MessageBoxButtons.OK, MessageBoxIcon.Question, _
       MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading _
          Or MessageBoxOptions.RightAlign)
    
    // C#
    MessageBox.Show("Text", "Caption", 
        MessageBoxButtons.OK, MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button1, 
        MessageBoxOptions.RtlReading
        | MessageBoxOptions.RightAlign);
    

See Also

Tasks

How to: Create Mirrored Windows Forms and Controls

Concepts

Bi-Directional Support for Windows Forms Applications

Other Resources

Localizing Applications