I have a DataGridView bound to a bindingsource which is bound to a List
. The user clicks a row that goes to a form with textboxes, etc. The textboxes a
A simpler approach would be to subscribe to the BindingSource's ListChanged event and set an IsDirty flag based on the event type.
categoryBindingSource.ListChanged +=
new System.ComponentModel.ListChangedEventHandler(categoryBindingSource_ListChanged);
and set IsDirty = true in the event method...
void customerAccountBindingSource_ListChanged(object sender, system.ComponentModel.ListChangedEventArgs e)
{
if (e.ListChangedType == System.ComponentModel.ListChangedType.ItemChanged)
_isDirty = true;
}
A word of caution here, it would not be able to detect when the modified value is still same as the original value. Memberwise.Clone
can be used additionally if that level of accuracy is required.