Sponsored By
MindStick Cleaner
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
   

Home >> .Net >> C# >> Result of clicking No button on a MessageBox dialog class.
Author Post

Awadhendra Tiwari


Total Post: 126
Member Since: 1/19/2011
Points: 893
Result of clicking No button on a MessageBox dialog class.
Posted On: 8/24/2011 1:13:19 AM
Hi all,
I have a following line of code
MessageBox.Show("Are you sure you want to download? Click 'YES' to Import (or) 'NO' to cancel", "Confirmation Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


I am trying to set it so that if the user clickes no, then it goes back to the original form and sets a button to visible and a label to invisible. I know the code to take care of the button and label, but I'm not sure how to take care of the result of the No button click.

Any help could be appreciated.
Thanks.
Author Post

James Smith


Total Post: 48
Member Since: 3/16/2011
Points: 270
Re: Result of clicking No button on a MessageBox dialog class.
Posted On: 8/24/2011 6:16:55 AM
Hi Awadhendra,

You can use DialogResult property for solving your problem. Like in following algorithm I will explain it.

if(MessageBox.Show("Click","Confirmation",MessageBox.OKCancel,MessageBoxIcon.Warning)==DialogResult.OK)
{
        //Write code if OK button is clicked.
}
else
{
      //Write code if other button is clicked.
}

Thanks.
Report Abuse Form
Reason:    
 
Total Online Users: 7201
Advertisement
MindStick DataConverter
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.