Using the latest MaskedEdit control I am attempting to bind the control to a BindingSource using a List of a CustomObjects, similar to...
List<Agency> agencies = GetAgencies();
agencyBindingSource.DataSource = agencies;
Within the Agency object there is a propery called ZipCode, which I am feeding to the MaskedEdit Value propery via DataBinding
this.zipCodeMasked.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.agencyBindingSource, "ZipCode", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
I also have a navigation control on the form that allows me to move through out the list and rebinds the controls to the Current object on the list. The strange behavior occurs when moving from one object that has a zipcode to another object that doesn't. When the first object has a ZipCode it appears within the control, however when moving to the next item that doesn't have a ZipCode, the control does not clear. Instead the next item appears to have the same ZipCode as the previous item.
I have use the following rework around...
List<Agency> agencies = GetAgencies();
agencyBindingSource.DataSource = agencies;
Within the Agency object there is a propery called ZipCode, which I am feeding to the MaskedEdit Value propery via DataBinding
this.zipCodeMasked.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.agencyBindingSource, "ZipCode", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
I also have a navigation control on the form that allows me to move through out the list and rebinds the controls to the Current object on the list. The strange behavior occurs when moving from one object that has a zipcode to another object that doesn't. When the first object has a ZipCode it appears within the control, however when moving to the next item that doesn't have a ZipCode, the control does not clear. Instead the next item appears to have the same ZipCode as the previous item.
I have use the following rework around...
var
agencyValues = (Agency)agencyBindingSource.Current;
if (agencyValues != null && !agencyValues.Zip.IsNotNullOrEmpty())
{
zipCodeMasked.Value =
null;
}