1

I have a messageBox with yes/no buttons. I want the it's string text be right to left, but the buttons location be at left. and I want to change the buttons text also...

I used the below code:

MessageBox.Show("abc", MessageBoxButtons.YesNo, MessageBoxIcon.None,
    MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);

but in this code, the buttons be on the left too. how can I set my personal change in it?

Dmitry
  • 13,797
  • 6
  • 32
  • 48
Elahe
  • 1,379
  • 2
  • 18
  • 34

3 Answers3

3

You can not edit this dialog; design your own MessageBox and customize it. For some limited options in this dialog see RightAlign or RtlReading options in MessageBoxOptions Enumeration.

example:

string message = "سلام";
string caption = "سلام";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(this, message, caption, buttons,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
    MessageBoxOptions.RightAlign);
Ria
  • 10,237
  • 3
  • 33
  • 60
1

As far as I Know you cannot change/edit the default MessageBox of winforms. However you can create a custom message box. Look at the Custom Message Box which might be helpful. You can also have a look at the previously asked question over here

Community
  • 1
  • 1
Vikneshwar
  • 1,029
  • 4
  • 20
  • 38
0

It is very hard to customize MessageBox outside the already provided options. RtlReading option is not meant to be used for cosmetic aligning, but to enable right-to-left scripts (such as Arabic) in left-to-right environment. What you really need is some custom message box. CodeProject has several, so maybe some of them may be useful to you. There are surely more out there on the 'net. When I go to http://www.codeproject.com/KB/dialog/ add filter for .NET and add search for messagebox this is what I get:

One article even describes how to extend system's existing message box, but I don't recommend that approach.

Community
  • 1
  • 1
Dialecticus
  • 16,400
  • 7
  • 43
  • 103