Ali why are you call
if (pResult == DialogResult.Yes)
{
this.Close();
return true;
}
else return false;
in case the dialog box = vbyes return true or false as per your need in example
private bool _Cancel(object sender, EventArgs e)
{
if (((this.textboxFirstName.Text != null) && (this.textboxFirstName.Text != string.Empty))
|| ((this.textboxLastName.Text != null) && (this.textboxLastName.Text != string.Empty)))
{
DialogResult pResult = MessageBox.Show("Do you want to cancel adding this driver?", "Warning", MessageBoxButtons.YesNo);
if (pResult == DialogResult.Yes)
{
//avoid => this.Close();
return true;
}
else return false;
}
else
{
// avoid => this.Close();
return true;
}
}