V
Vladimir Nesterovsky
I've found this curious code in the System.Windows.Forms.dll:
Class: System.Windows.Forms.BindToObject
internal void CheckBinding()
{
if (((this.owner == null) ||
(this.owner.BindableComponent == null)) ||
!this.owner.ControlAtDesignTime())
{
if (((this.owner.BindingManagerBase != null) &&
(this.fieldInfo != null)) &&
(this.owner.BindingManagerBase.IsBinding &&
!(this.owner.BindingManagerBase is CurrencyManager)))
{
this.fieldInfo.RemoveValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
if ((((this.owner != null) &&
(this.owner.BindingManagerBase != null)) &&
((this.owner.BindableComponent != null) &&
this.owner.ComponentCreated)) &&
this.IsDataSourceInitialized)
{
string text1 = this.dataMember.BindingField;
this.fieldInfo =
this.owner.BindingManagerBase.GetItemProperties().Find(text1, true);
if (((this.owner.BindingManagerBase.DataSource != null) &&
(this.fieldInfo == null)) && (text1.Length > 0))
{
object[] objArray1 = new object[] { text1 } ;
throw new ArgumentException(
SR.GetString("ListBindingBindField", objArray1),
"dataMember");
}
if (((this.fieldInfo != null) &&
this.owner.BindingManagerBase.IsBinding) &&
!(this.owner.BindingManagerBase is CurrencyManager))
{
this.fieldInfo.AddValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
}
else
{
this.fieldInfo = null;
}
}
}
Estimate it. Cheer!
P.S. decompiled with .NET Reflector.
Class: System.Windows.Forms.BindToObject
internal void CheckBinding()
{
if (((this.owner == null) ||
(this.owner.BindableComponent == null)) ||
!this.owner.ControlAtDesignTime())
{
if (((this.owner.BindingManagerBase != null) &&
(this.fieldInfo != null)) &&
(this.owner.BindingManagerBase.IsBinding &&
!(this.owner.BindingManagerBase is CurrencyManager)))
{
this.fieldInfo.RemoveValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
if ((((this.owner != null) &&
(this.owner.BindingManagerBase != null)) &&
((this.owner.BindableComponent != null) &&
this.owner.ComponentCreated)) &&
this.IsDataSourceInitialized)
{
string text1 = this.dataMember.BindingField;
this.fieldInfo =
this.owner.BindingManagerBase.GetItemProperties().Find(text1, true);
if (((this.owner.BindingManagerBase.DataSource != null) &&
(this.fieldInfo == null)) && (text1.Length > 0))
{
object[] objArray1 = new object[] { text1 } ;
throw new ArgumentException(
SR.GetString("ListBindingBindField", objArray1),
"dataMember");
}
if (((this.fieldInfo != null) &&
this.owner.BindingManagerBase.IsBinding) &&
!(this.owner.BindingManagerBase is CurrencyManager))
{
this.fieldInfo.AddValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
}
else
{
this.fieldInfo = null;
}
}
}
Estimate it. Cheer!
P.S. decompiled with .NET Reflector.