Click or drag to resize
ControlBinder Class
The base class for all control binders.
Inheritance Hierarchy

Namespace: VirtualRadar.WinForms.PortableBinding
Assembly: VirtualRadar.WinForms (in VirtualRadar.WinForms.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public abstract class ControlBinder : IDisposable

The ControlBinder type exposes the following members.

Constructors
  NameDescription
Public methodControlBinder
Creates a new object.
Top
Properties
  NameDescription
Public propertyControlObject
Gets the control that has been bound to the model.
Public propertyControlValueObject
Gets the value of the control.
Public propertyInitialised
Gets a value indicating that the object has been initialised.
Public propertyModelObject
Gets the model that has been bound to the control.
Public propertyModelValueObject
Gets the value of the model.
Public propertyUpdateMode
Gets or sets an indication of when values are copied from the control to the model. Cannot be modified once the binder has been initialised.
Top
Methods
  NameDescription
Protected methodChangeModelObject
Changes the model object.
Public methodCopyControlToModel
Refreshes the model's content with the content of the control.
Public methodCopyModelToControl
Refreshes the control's content with the content of the model.
Public methodDispose
See interface docs.
Protected methodDispose(Boolean)
Finalises or disposes of the object.
Protected methodDoCopyControlToModel
Does the actual work of copying the value from the control to the model.
Protected methodDoCopyModelToControl
Does the actual work of copying the value from the model to the control.
Protected methodDoHookControl
Performs the actual work of hooking the control. Can be overridden.
Protected methodDoHookControlPropertyChanged
Overridden to hook the control event that is raised as soon as the user changes the control's value.
Protected methodDoHookModel
Performs the actual work of hooking the model. Can be overridden.
Protected methodDoInitialiseControl
Does the work of initialising the control. By default this just calls CopyModelToControl.
Protected methodDoInitialising
Called before any initialisation is performed, specifically before anything is hooked. Can be overridden to perform setup that must be in place before any event handlers can be called.
Protected methodDoUnhookControl
Performs the actual work of unhooking the control. Can be overridden.
Protected methodDoUnhookControlPropertyChanged
Overridden to unhook the control event that is raised as soon as the user changes the control's value.
Protected methodDoUnhookModel
Performs the actual work of unhooking the model. Can be overridden.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Finalises the object.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodHookControl
Hooks the events on the control.
Protected methodHookModel
Hooks the events on the model.
Public methodInitialise
Initialises the binder. Must be called before the binder will start working.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodUnhookControl
Unhooks the events on the control.
Protected methodUnhookModel
Unhooks the events on the model.
Top
Fields
  NameDescription
Protected field_UpdatesLocked
True if changes are not to be copied between the control and the model.
Top
Remarks

This takes care of the basics of binding models to controls. It tries not make too many assumptions about the nature of the binding - that's for derived classes to do.

ControlBinders have optional properties that can be configured before use - once Initialise has been called these properties can no longer be set. You can make multiple calls on Initialise but the second and subsequent calls do nothing.

ControlBinders must be disposed of in order to release the event hooks. If you do not dispose of them then the controls that they are hooking will remain in memory for the lifetime of the model. Forms and UserControls based on BaseForm and BaseUserControl automatically dispose of any ControlBinders that have been registered with AddControlBinder.

See Also