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

prevent user from moving off current row when data changed

P: n/a
Greetings!

I have a simple Windows form for editing. Search results are bound to
a bindingsource and shown in a datagrid paired with a datanavigator.
The current row's data is displayed in text boxes bound to the same
bindingsource. I'd like to present a save / cancel dialog if the user
changes the current data and attempts to navigate away from the current
record. There's a ColumnChangingEvent on the underlying data object.
I check if (e.ProposedValue.ToString() !=
e.Row[e.Column.ColumnName].ToString()) to detect dirty, but I can't
find a cancelable event that fires when navigation is about to happen.
Could check dirty on the navigator buttons, but that wouldn't prevent
the user from just clicking on another row in the datagridview. I see
events like datagridview.rowleave but I'd have to detect dirty and this
event isn't cancelable. Bindingsource.currentchanged fires after the
pointer has landed on a new row and doesn't look like it's cancelable
anyway.

I know I must be missing something obvious. Help!

TIA,
Jay

Dec 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jay,,

Why do you have to detect dirty. If you use a datatable the haschanges is
perfect to see if there are changes. (The dirty term is Java, in Net it goes
very clean).

Cor

<ja**********@gmail.comschreef in bericht
news:11*********************@42g2000cwt.googlegrou ps.com...
Greetings!

I have a simple Windows form for editing. Search results are bound to
a bindingsource and shown in a datagrid paired with a datanavigator.
The current row's data is displayed in text boxes bound to the same
bindingsource. I'd like to present a save / cancel dialog if the user
changes the current data and attempts to navigate away from the current
record. There's a ColumnChangingEvent on the underlying data object.
I check if (e.ProposedValue.ToString() !=
e.Row[e.Column.ColumnName].ToString()) to detect dirty, but I can't
find a cancelable event that fires when navigation is about to happen.
Could check dirty on the navigator buttons, but that wouldn't prevent
the user from just clicking on another row in the datagridview. I see
events like datagridview.rowleave but I'd have to detect dirty and this
event isn't cancelable. Bindingsource.currentchanged fires after the
pointer has landed on a new row and doesn't look like it's cancelable
anyway.

I know I must be missing something obvious. Help!

TIA,
Jay

Dec 28 '06 #2

P: n/a
What event can I check HasChanges in that occurs as the user is moving
off the current record?

Cor Ligthert [MVP] wrote:
Jay,,

Why do you have to detect dirty. If you use a datatable the haschanges is
perfect to see if there are changes. (The dirty term is Java, in Net it goes
very clean).

Cor

<ja**********@gmail.comschreef in bericht
news:11*********************@42g2000cwt.googlegrou ps.com...
Greetings!

I have a simple Windows form for editing. Search results are bound to
a bindingsource and shown in a datagrid paired with a datanavigator.
The current row's data is displayed in text boxes bound to the same
bindingsource. I'd like to present a save / cancel dialog if the user
changes the current data and attempts to navigate away from the current
record. There's a ColumnChangingEvent on the underlying data object.
I check if (e.ProposedValue.ToString() !=
e.Row[e.Column.ColumnName].ToString()) to detect dirty, but I can't
find a cancelable event that fires when navigation is about to happen.
Could check dirty on the navigator buttons, but that wouldn't prevent
the user from just clicking on another row in the datagridview. I see
events like datagridview.rowleave but I'd have to detect dirty and this
event isn't cancelable. Bindingsource.currentchanged fires after the
pointer has landed on a new row and doesn't look like it's cancelable
anyway.

I know I must be missing something obvious. Help!

TIA,
Jay
Dec 29 '06 #3

P: n/a
You can check the datatable, on any place as you do that after the command
datasource.endedit in version 2005 or currencymanager.endcurrentedit in the
older versions.

Cor

<ja**********@gmail.comschreef in bericht
news:11**********************@a3g2000cwd.googlegro ups.com...
What event can I check HasChanges in that occurs as the user is moving
off the current record?

Cor Ligthert [MVP] wrote:
>Jay,,

Why do you have to detect dirty. If you use a datatable the haschanges is
perfect to see if there are changes. (The dirty term is Java, in Net it
goes
very clean).

Cor

<ja**********@gmail.comschreef in bericht
news:11*********************@42g2000cwt.googlegro ups.com...
Greetings!

I have a simple Windows form for editing. Search results are bound to
a bindingsource and shown in a datagrid paired with a datanavigator.
The current row's data is displayed in text boxes bound to the same
bindingsource. I'd like to present a save / cancel dialog if the user
changes the current data and attempts to navigate away from the current
record. There's a ColumnChangingEvent on the underlying data object.
I check if (e.ProposedValue.ToString() !=
e.Row[e.Column.ColumnName].ToString()) to detect dirty, but I can't
find a cancelable event that fires when navigation is about to happen.
Could check dirty on the navigator buttons, but that wouldn't prevent
the user from just clicking on another row in the datagridview. I see
events like datagridview.rowleave but I'd have to detect dirty and this
event isn't cancelable. Bindingsource.currentchanged fires after the
pointer has landed on a new row and doesn't look like it's cancelable
anyway.

I know I must be missing something obvious. Help!

TIA,
Jay

Dec 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.