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
C#
privatevoidTabControlChars_Leave(object sender, EventArgs e)
{
DataTable charChanges = null;
if (charsTypeDT != null)
{
charChanges = charsTypeDT.GetChanges();
}
elseif (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)
{
???
}
}
}
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 18, 2009, 8:44 PM EST
Replace your question marks with following code and see.
((Control)sender).Focus();
If it doesnt help you let me know.
If you find it useful, please accept this answer.