Technologies: C#, .Net, Winforms
I have a main form that pulls data from a database, and populates numerous different controls. Labels, Textboxes, DataRepeaters, DataGridViews, and tabs filled with those kinds of controls as well.
However, the data is also being pulled in such a way that there are multiple "records" on this form being navigated by a BindingNavigator.
Because of the structure of my code, I can't easily call a DataAdaptor.update() on whatever control is being validated, (using it's associated DataTable) so I'm just going to use a commit button instead.
What I'd like to know is "How do I check all the controls to see if they've been edited?"
I'm using the binding Navigator buttons as the trigger to "FindEditedControls()"
Current Solution:
DataTable dt = db.GetTable();
dt.RowChanged += new DataRowChangeEventHandler(dtUpdated);
private void dtUpdated(object sender, DataRowChangeEventArgs e)
{
needsCommit = true;
}
And the button just checks the needsCommit boolean variable. If it's true, then it asks the user to commit the changes before continuing. If they click "Yes" then it commits the data to the database.
If this is what you were getting, I want to thank you. This works very nicely with DataGridViews. Now to test it with standard form controls.
Hook up to the DataTable.RowChanged
event. When it fires, one of your controls has been edited.
Then, you can check the DataRow.RowState
property for a value of DataRowState.Modified
for the rows you are binding to.
assign a signature to every control from data bounded to it then check that signature with the values of the control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.