prevent user from moving off current row when data changed

J

jay.meerdink

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
 
C

Cor Ligthert [MVP]

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
 
J

jay.meerdink

What event can I check HasChanges in that occurs as the user is moving
off the current record?
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

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
 
C

Cor Ligthert [MVP]

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

What event can I check HasChanges in that occurs as the user is moving
off the current record?
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top