Reputation: 660
I am using following code for showing a MessageBox with ok and cancel button. When I click any button same message box appears again. Is there any problem in this code?
string messageBoxText = "Uploading Data";
string caption = "Upload Data";
MessageBoxButton button = MessageBoxButton.OKCancel;
// Display message box
MessageBox.Show(messageBoxText, caption, button, icon);
MessageBoxResult res = MessageBox.Show(messageBoxText, caption, button, icon);
if (res == MessageBoxResult.OK)
{
count++;
}
Upvotes: 0
Views: 1069
Reputation: 6490
You are calling message box twice via MessageBox.Show
. You might want to remove the first
MessageBox.Show(messageBoxText, caption, button, icon);
Upvotes: 2
Reputation: 863
Because you are calling MessageBox.Show
two times...
string messageBoxText = "Uploading Data";
string caption = "Upload Data";
MessageBoxButton button = MessageBoxButton.OKCancel;
// Display message box
MessageBox.Show(messageBoxText, caption, button, icon); //**Comment this line**
MessageBoxResult res = MessageBox.Show(messageBoxText, caption, button, icon);
if (res == MessageBoxResult.OK)
{
count++;
}
Upvotes: 5