9using System.Collections.Generic;
10using System.ComponentModel;
11using System.Windows.Forms;
31 _source.CurrentChanged += BindingSource_CurrentChanged;
34 private BindingSource _source;
35 private List<BindingSourceNode> _children;
38 private void BindingSource_CurrentChanged(
object sender, EventArgs e)
40 if (_children.Count > 0)
42 child.Source.EndEdit();
45 internal BindingSource Source
47 get {
return _source; }
50 internal List<BindingSourceNode> Children
54 if (_children ==
null)
55 _children =
new List<BindingSourceNode>();
63 get {
return _parent; }
64 set { _parent = value; }
67 internal void Unbind(
bool cancel)
72 if (_children.Count > 0)
76 IEditableObject current = _source.Current as IEditableObject;
78 if (!(_source.DataSource is BindingSource))
79 _source.DataSource =
null;
89 if (_source.DataSource is BindingSource)
90 _source.DataSource = _parent.Source;
93 internal void EndEdit()
98 if (_children.Count > 0)
105 internal void SetEvents(
bool value)
110 _source.RaiseListChangedEvents = value;
112 if (_children.Count > 0)
114 child.SetEvents(value);
117 internal void ResetBindings(
bool refreshMetadata)
122 if (_children.Count > 0)
124 child.ResetBindings(refreshMetadata);
126 _source.ResetBindings(refreshMetadata);
135 public void Bind(
object objectToBind)
142 _source.DataSource = objectToBind;
144 ResetBindings(
false);
167 public void Cancel(
object businessObject)
178 Bind(businessObject);
Maintains a reference to a BindingSource object on the form.
void Close()
Disconnects from the BindingSource object.
void Apply()
Applies changes to the business object.
void Cancel(object businessObject)
Cancels changes to the business object.
BindingSourceNode(BindingSource source)
Creates an instance of the object.
void Bind(object objectToBind)
Binds a business object to the BindingSource.
Define the common methods used by the UI to interact with n-level undo.
void CancelEdit()
Cancels the current edit process, restoring the object's state to its previous values.
void ApplyEdit()
Commits the current edit process.
void BeginEdit()
Starts a nested edit on the object.