I want to show confirmation Box in C# code. I've seen above solution for that but it shows me exception at 'Yes' as 'System.Nullable' does not contain definition for 'Yes'. How should I remove this error?
private void listBox1_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { if (sender is ListBoxItem) { ListBoxItem item = (ListBoxItem)sender; Harvest_TimeSheetEntry entryToDelete = (Harvest_TimeSheetEntry)item.DataContext; DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) // error is here { Globals._globalController.harvestManager.deleteHarvestEntry(entryToDelete); } else { System.Windows.MessageBox.Show("Delete operation Terminated"); } } }
A confirm box is often used if you want the user to verify or accept something. A confirm box takes the focus away from the current window, and forces the user to read the message.
Solution 4createElement("INPUT"); confirm_value. type = "hidden"; confirm_value.name = "confirm_value"; if (confirm("Do you want to save data?")) { confirm_value. value = "Yes"; } else { confirm_value. value = "No"; } document.
Instead of using WinForm MessageBox, use the MessageBox provided by WPF and later use MessageBoxResult
instead of DialogResult
in WPF.
like:
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) //...........
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With