G
GS
How do I properly detect row change before allowing moving to next row?
I tried using RowLeave .
here is brief descript of the form setup.
I have
ieStringTmpDataSetwith regex table connected to a SQL mdf.,
on the form I have a regexDataGridView for the table regex for
navigation and viewing purpose only
also the associated navigator, detail view controls bounded with the
same binding source for editing.
so the current row of the regexDataGridView is shown on the detail view
controls
here is the code for the Rowleave Event
DataRow[] dr = ieStringTmpDataSet.Regex.Select("", "",
DataViewRowState.ModifiedCurrent);
int irowsChgd = dr.GetUpperBound(0) + 1;
if (regexDataGridView.IsCurrentRowDirty | irowsChgd > 0)
{
DialogResult dlgReslt = MessageBox.Show("Save Changes?",
this.Text + " - The row has unsaved changes",
MessageBoxButtons.YesNo);
if (dlgReslt == DialogResult.Yes)
{
regexBindingNavigatorSaveItem.PerformClick();
setStatus("Saved change to regex " +
regexNameTextBox.Text);
}
else
{ //' problem with cancelling change, cancel edit does not
work
regexDataGridView.CancelEdit();
ieStringTmpDataSet.RejectChanges();
// causes exception later:
ieStringTmpDataSet.Regex.Reset();
setStatus("Change to regex is still pending for " +
irowsChgd + " rows. Please reload to forget change");
}
}
else if (statusLabel.Text != "Ready") setStatus("Ready");
Problem: the event tend to delay prompting until 2nd row leave after a row
has been modified
your help to show me the propeway to detect modifcation is much appreciated.
thank you for your time and advice
Btw regexDataGridView.IsCurrentRowDirty always returns false
I tried using RowLeave .
here is brief descript of the form setup.
I have
ieStringTmpDataSetwith regex table connected to a SQL mdf.,
on the form I have a regexDataGridView for the table regex for
navigation and viewing purpose only
also the associated navigator, detail view controls bounded with the
same binding source for editing.
so the current row of the regexDataGridView is shown on the detail view
controls
here is the code for the Rowleave Event
DataRow[] dr = ieStringTmpDataSet.Regex.Select("", "",
DataViewRowState.ModifiedCurrent);
int irowsChgd = dr.GetUpperBound(0) + 1;
if (regexDataGridView.IsCurrentRowDirty | irowsChgd > 0)
{
DialogResult dlgReslt = MessageBox.Show("Save Changes?",
this.Text + " - The row has unsaved changes",
MessageBoxButtons.YesNo);
if (dlgReslt == DialogResult.Yes)
{
regexBindingNavigatorSaveItem.PerformClick();
setStatus("Saved change to regex " +
regexNameTextBox.Text);
}
else
{ //' problem with cancelling change, cancel edit does not
work
regexDataGridView.CancelEdit();
ieStringTmpDataSet.RejectChanges();
// causes exception later:
ieStringTmpDataSet.Regex.Reset();
setStatus("Change to regex is still pending for " +
irowsChgd + " rows. Please reload to forget change");
}
}
else if (statusLabel.Text != "Ready") setStatus("Ready");
Problem: the event tend to delay prompting until 2nd row leave after a row
has been modified
your help to show me the propeway to detect modifcation is much appreciated.
thank you for your time and advice
Btw regexDataGridView.IsCurrentRowDirty always returns false