7 Years
Discussion Span
Last Post by serkan sendur
Featured Replies

I should say: overide the Show method of the MessageBox class.
In the overide play the sound(async), then Show the messagebox.


instead of code snippets i find it more useful to attach project to a post. then the poster can download and run right away, this is like a codeproject approach. dont you agree?


I fully agree.
But since you classified me as only capable of answering simple questions(which is all I do and can do in fact) I (with my simple mind) thought you where able to figure out all the rest for yourself. Correct me if I am wrong.:|


Rest assured, you are not offending me in any way.
In fact I like your style. The only thing is: don't overdo it!;)


Serkan always overrides technical thread to personal one, really if you are banned I'll upset not having you around, but still I'll be sure there are no more replies in threads :D


I should say: overide the Show method of the MessageBox class.
In the overide play the sound(async), then Show the messagebox.

according to this guy i cant override messagebox.show(), why?

This is old, nevertheless, you can create a derived MessageBox class, but the Show method of the  MessageBox class is static.  Therefore it's possible to override the MessageBox class, but you won't be able to override the Show method.

So, the following line will work.

public static MyMessageBox : MessageBox  

but you won't be able to do this:

public static override MessageBoxResult Show( string messageBoxText )  

Therefore, it is possible to override the messagebox class, but the one function that is acutally useful can not be overriden.

You could also just create a class called MessageBox in your application with static Show methods that match the framework MessageBox class.  You could then use namespaces to switch between your MessageBox class and the framework MessageBox class.

public static MessageBox  
public static MessageBoxResult Show( string messageBoxText )  
return System.Windows.Forms.MessageBox.Show( messageBoxText );  

Any of the other suggestions on this page should also suffice.



in another thread it says :

As to specifically overriding that method, you cant. You can't derive classes from static classes, so you wouldn't be able to create a child class that you could override the method in.


i dont see any static keyword before the class definition in the metadata? how do i know that class is static in .net framework?

that is why i asked for a code example ddanbe..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.