Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox.Show right to left reading not working

Hey I'll make it simple. I want to make a MessageBox of this string "abc" and it will be read from right to left.

I tried this Messagebox.Show("abc",MessageBoxOptions.RtlReading);

what's worng with this ?

this is the error i get :

1:"cannot convert from 'System.Windows.Forms.MessageBoxOptions' to 'string"

2:"cannot convert from 'string' to 'System.Windows.Forms.MessageBoxButtons'"

3:"The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string, string)' has some invalid arguments"

like image 603
Shmulik Cohen Avatar asked Jun 07 '13 21:06

Shmulik Cohen


People also ask

What is return type of show () method of MessageBox class?

DialogResult is an enumeration of the possible return values of a dialog box including a MessageBox. The Show method returns a DialogResult that tells us what button a user has clicked on the message box.

What is the 2nd parameter in MessageBox show ()?

The first parameter msg is the string displayed in the dialog box as the message. The second and third parameters are optional and respectively designate the type of buttons and the title displayed in the dialog box. MsgBox Function returns a value indicating which button the user has chosen.

Which of the following is default button of MessageBox control?

MessageBox with Default Button By default, the first button is the default button. The MessageBoxDefaultButton enumeration is used for this purpose and it has the following three values. The following code snippet creates a MessageBox with a title, buttons, and an icon and sets the second button as a default button.

How do I display message box?

To display a message box, call the static method MessageBox. Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.


3 Answers

If it's not displaying left to right, try this:

//note the capitalized B in Box
MessageBox.Show(new string("abc".Reverse()), "", MessageBoxButtons.OK, MessageBoxIcons.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

If you want something like this:

----------------------------X--
-------------------------------
|                             |
|                             |
|                        cba  |
|                             |
|                        |OK| |
-------------------------------

I think it doesn't have to do with that though, it's mainly you got the parameters wrong. wrong. Here, fixed:

//note the capitalized B in Box
MessageBox.Show("abc", "", MessageBoxButtons.OK, MessageBoxIcons.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading);

There's also an ugly way to do this, but it means you don't have to add the extraparams. First, make a class called MessageBoxEx, and the contents of it are...

static class MessageBoxEx
{
    public static void Show(string content, MessageBoxOptions options)
    {
        MessageBox.Show(content, "", MessageBoxButtons.OK, MessageBoxIcons.None,          MessageBoxDefaultButton.Button1, options);
    }
}

and call it like MessageBoxEx.Show("abc", MessageBoxOptions.RtlReading);.

like image 186
It'sNotALie. Avatar answered Sep 20 '22 04:09

It'sNotALie.


Write a method that will default all the values you don't want to set.

//Message is the string message and options is where you specify RTL
public void ShowMessageBox(string message, MessageBoxOptions options)
{
    MessageBox.Show(message, "", MessageBoxButtons.OK, MessageBoxIcons.None, MessageBoxDefaultButton.Button1, options);
}

Then all you have to do is call

ShowMessageBox("abc", MessageBoxOptions.RtlReading)
like image 23
Darlene Avatar answered Sep 23 '22 04:09

Darlene


I have been in situation like this, and the best way I found is to combine the two flags: RtlReading and RightAlign:

MessageBox.Show("Msg body", "Msg title", MessageBoxButton.OK, MessageBoxImage.Warning, 
         MessageBoxResult.OK, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
like image 38
H Aßdøµ Avatar answered Sep 23 '22 04:09

H Aßdøµ