Answered Confirmation Box Code Error

  • Friday, April 06, 2012 4:42 PM
     
      Has Code

    I'm setting up a confirmation box for clearing out a .txt file filled with raw data. Whether or not the action can complete is dependent on whether the "write data to file" box is checked- otherwise, you're going to try to delete something that doesn't exist. I'm getting an error:

    Error 1 'System.Nullable<bool>' does not contain a definition for 'Yes' and no extension method 'Yes' accepting a first argument of type 'System.Nullable<bool>' could be found (are you missing a using directive or an assembly reference?)

    while using this chunk of code:

    private void reset_data_Click(object sender, RoutedEventArgs e)
            {
               
                if (MessageBox.Show("This operation will clear the .txt file. It cannot be undone.","Do you wish to continue?", MessageBoxButton.YesNo)==DialogResult.Yes)
                    {
    
                    }
                else if(chkOutput.IsChecked == false)
                	{
                    	MessageBox.Show("No output file was created at the beginning of this program. This operation will have no effect");
                	}
            }	

    It's not happy about the "DialogResult.Yes". How do I fix this? I saw this particular bit of code posted quite a bit on the web... it's a fairly simple operation, so what am I doing wrong?

    • Moved by CoolDadTxMVP Friday, April 06, 2012 5:09 PM WPF related (From:Visual C# General)
    •  

All Replies