All, I understand that for extensively customised dialogs I would need to create my own form and ShowDialog()
. However, in my current case I would just like to extend the MessageBox class to facilitate a CustomMessageBox
that is capable of showing different icons insted of those determined by the system.
I have not overridden such a control before and I am not even sure where to start. Could someone point me in the right direction?
Thanks for your time.
No, you cannot override MessageBox. Show because it is a static method.
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.
Message Box is a class in the “Systems. Windows. Forms” Namespace and the assembly it is available is “System. Windows.
MessageBox
is not a control actually (doesn't inherit from Control
), it's just a class.
Actually, it's even almost a static
class, as there is no public/protected constructor defined, and only static
methods. It's more like a factory.
You probably should write your own, as it's not extendable.
You can't customize MessageBox like that, unfortunately. You will have to roll-your-own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With