Eyal Lewin

Eyal Lewin

  • NA
  • 18
  • 0

how to avoid a leave event after it is called

Nov 19 2009 1:32 AM
hello,
im looking for a solution with a slight problem that im sure it is possible, but i cant find anything about it on the web.
In my code, im calling a leave event out of a control that check's if the control has made any changes (txtBox, combo Box...) raising a question telling the user that changes weren't saved.
if the user click's on Cancel button, i want him to stay in the control and not actually leave like he initially did.
How can i do it ?
Thanks

 private void TabControlChars_Leave(object sender, EventArgs e)
{
DataTable charChanges = null;

if (charsTypeDT != null)
{
charChanges = charsTypeDT.GetChanges();
}
else if (charsDT != null)
{
charChanges = charsDT.GetChanges();
}

if (charChanges != null)
{
DialogResult result;
result = MessageBox.Show("Changes were made without saving !!\n"
+ "All Changes will be lost ...", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (result == DialogResult.Cancel)
{
???
}
}
}




Answers (1)