Search code examples
c#messagebox

How to remove MessageBox Buttons?


I want to delete the buttons in a message box such as (yes, YesNo, OK ...), but not the close button. I found no way to do this unless deleting the parameter as well, but I can't do so since I need to add options parameters to my message box.


Solution

  • I agree with @NDJ, the cleanest and most straight forward solution is to build your own message box based on a Form. To modify the actual MessageBox would require lots of low level Windows APIs like in this example. (That project is modifying the Text on the buttons. You would need additional APIs to hide them; the MessageBox wouldn't resize though.)

    *I'm not recommending you use the API approach...I'm just showing you how much effort and code it would take!