By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

the proper way to detect changes to current row before moving to next row

P: n/a
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
Dec 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Dec 31, 9:58*am, "GS" <gsmsnews.microsoft.co...@msnews.Nomail.com>
wrote:
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
Try using the RowValidating event. Inside the
DataGridViewCellCancelEventArgs is the Cancel property for this Row.
Greg
Jan 1 '08 #2

P: n/a
GS
uh...., the event seems to be called regardless if the are changes. just
change to a different row, will trigger it to fire until one replies yes
unless I put in a test query for dirty row

then I will face the same problem of missing the prompt on first row change
after a row is modified

"Greg" <gc*****@gmail.comwrote in message
news:8c**********************************@i12g2000 prf.googlegroups.com...
On Dec 31, 9:58 am, "GS" <gsmsnews.microsoft.co...@msnews.Nomail.com>
wrote:
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
Try using the RowValidating event. Inside the
DataGridViewCellCancelEventArgs is the Cancel property for this Row.
Greg
Jan 1 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.