Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I Want To Make A Message Box When I press {Exit} Button (In Any programe) include (Yes No) Buttons And Question Mark Can You give me the code to do That ? :)
Posted

C#
public static void Main(string[] args) {
    // Starts the application.
    Application.Run(new Form1());
 }
 protected void button1_Click(object sender, System.EventArgs e) {
    // Populates a list box with three numbers.
    int i = 3;
    for(int j=1; j<=i; j++) {
       listBox1.Items.Add(j);
    }
    /* Determines whether the user wants to exit the application.
     * If not, adds another number to the list box. */
    while (MessageBox.Show("Exit application?", "", MessageBoxButtons.YesNo) ==
       DialogResult.No) {
       // Increments the counter ands add the number to the list box.
       i++;
       listBox1.Items.Add(i);
    }
    // The user wants to exit the application. Close everything down.
    Application.Exit();
 }
 
Share this answer
 
v2
Are you developing web application or windows application?

If windows, then use this:
MessageBox.Show("Your Message","Your Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


If web application, you need to write javascripts for displaying messagebox.
 
Share this answer
 
Comments
Member 12355159 27-Feb-16 4:04am    
messagebox's name space?
You mean you have some sort of physical impairment that prevents you from using google? Here's the first of over 570 THOUSAND results returned with the search phrase "C# messagebox".

http://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox%28VS.71%29.aspx[^]
 
Share this answer
 
Try Google, or use MSDN:
MessageBox.Show("When I press {Exit} Button",
                "(In Any programe)",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question);
 
Share this answer
 

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