Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
how i can change the BackgroundImage of the message box on windows forms ????
Posted

You can't. See this[^] link for alternative approaches.

/ravi
 
Share this answer
 
Here at Code Project, we have even an article on that: "A Custom Message Box"[^].
 
Share this answer
 
Comments
Karthik_Mahalingam 23-Jan-14 23:46pm    
5
As Ravi said: "you can't."

All the substitute customizable Message Boxes you'll find, including the ones linked to in this thread, use a Form, and use 'ShowDialog to display the Form for very good reasons, including:

1. native WinForms Dialogs do some complex stuff to suspend the Message Pump to the Application's other windows while they hog the UI Events. Forms shown modally do the same: to reproduce that functionality you will have to have teeth pulled. Example: [^]. Trust me you don't want to go there.

2. You can use the DialogResult Enumeration value returned when a Form shown modally closes.

3. The convenience of having Buttons you can set the DialogResult property of in the Property Browser at design-time.

But, I'd encourage you to think about the fact that the way a Dialog looks-and-feels, and behaves, is something that Windows users are socialized to; the set of visual cues, and typical Control decorations ("Close," "Save," "Cancel," etc.) have meaning.

I suggest you consider that if the purpose of your Dialog UI is not similar to standard Win Dialogs, you reconsider the value of "going modal." If you really need to display another Form, you can display it "semi-modal" by setting its 'TopLevel and 'TopMost properties as needed.

But, if you gotta go modal, then I'd suggest deliberately making the look-and-feel of your Form shown modally different from the standard Dialogs, and make sure its design communicates to end-users its purpose. ... Quite likely that is your goal at this time :)

If you really desire a code example of using a secondary Form modally, just ask.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 23-Jan-14 23:48pm    
5!yes bill you are right,
CPallini solution is a good alternative...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900