-
Help with MessageBoxes
greetings to all,
i created a form (EletronicDiary) which has a button to open another form(Add New Appointment) -->
Code:
Appointment_AddScreen^ addApointForm = gcnew Appointment_AddScreen();
addApointForm->ShowDialog();
when i click on CANCEL, a messageBox appears to cofirm my decision(with buttons YES NO). My problem is no matter my decision of Yes or No, the add new appointment form closes. Please i need advice on what to do so that when i click on NO, my form doesnt close. Below is the code
Code:
private: System::Void btnAddCancel_Click(System::Object^ sender, System::EventArgs^ e) {
System::Windows::Forms::DialogResult result;
result = MessageBox::Show("Are you sure you want to exit?\nUnsaved entries will be lost!","Confirm Exit",MessageBoxButtons::YesNo,MessageBoxIcon::Warning);
if (result == System::Windows::Forms::DialogResult::Yes)
{
this->Close();
}
}
attached is an image for futher clarification
NB even if the IF statement is not present, the form still closes after Yes or No is clicked