Replacing with yes / no / cancel MessageBox (C #)

I am looking for a decent replacement for standard YES / NO or YES / NO / CANCEL MessageBox windows.

I often saw that these standard dialogs are used incorrectly, for example: “To save in the text answer“ YES ”or to save the answer“ NO ”in the html. Obviously, the text should read“ Save as: and the buttons ”should be marked as“ Text "and" HTML. "This is not a yes / no question that is asked, and although it could be formulated in this way, it would not be easy to read and understand.

Microsoft does not allow you to change the text on the buttons. There is no quick / easy way to create a replacement from scratch ... as evidenced by the number of applications using the awkward style mentioned above.

Is there a free C # or MessageBox replacement dialog that allows you at least:
- indicate the number of buttons
- specify the text that will be displayed on each button
- specify the default button

I looked and could not find it.

(I would build it myself, but I am not familiar enough with all the types of behavior that a fully functional control should have, since I need / use / know a small subset. Two examples that I do not use: themes and internationalization. I need something that my colleagues will also want to use.)

+4
source share
4 answers

Check out Unzip MessageBox in CodeProject. The project is a bit outdated, but to a large extent it is exactly what you are looking for, and it does not need to be updated much.

+6
source

Depending on your target platform, dialogue may be a good way to do this. There is a .NET wrapper for task dialogs in the Windows API Code Code . However, they are provided only in Windows Vista and higher, and not in XP or 2003.

+3
source

Honestly, creating such a Messagebox is not so difficult, we have such work that works in the current application that we are developing.

You will need FlowLayout for buttons that will automatically align any buttons you create. Now our API has something like (params Tuple <string, DialogResult> [])

Tuple is a helper class that contains two values. A string is the text of a button, a dialog box is one that is returned by our message when a button with the specified text is pressed.

+2
source

I agree with Frank. It would not be too difficult to create your own general form that handles this for you. Without going into the code, the form should do the following

1) You have the property to set the message that you want to show to the user.

2) Have a method for adding buttons, with two arguments, one for the button text and one for the result of the dialog

3) When the form is displayed, it should be in modal dialog mode, so that the rest of the application is inactive until one of the options is clicked.

So, to create Save As / Do not Save / Cancel, you would add 3 buttons in step 2, all with the corresponding button text and the result of the dialog.

Using the Flow layout, you should be able to display it correctly, regardless of message size or number of buttons.

+2
source

All Articles