Hello,I developed a user control that implements IBusinessBindable interface. The control has one textbox and bunch of buttons. Textbox text is a bindable property, and it's exposed through a custom property IndexText. The control DataSourceUpdateMode is set to DataSourceUpdateMode.OnPropertyChanged (see control code snippet below)
Everything works, but when user clicks on the textbox without changing anything, the BO states becomes Dirty. How can I get arround that?
string
_indexText = string.Empty;public string IndexText{
get { return _indexText;//syntaxEditorIndexText.Text; }
set{
_indexText =
value;syntaxEditorIndexText.Text = _indexText;
//syntaxEditorIndexText.Text = value; }
}
#region
IBusinessBindable Membersprivate BusinessLayer _BusinessObject;private string _BindingField = "";private string _BindingFormat = "";private string _BindingProperty = "IndexText";private bool _IgnoreManageUIReadOnlyState = true;private DataSourceUpdateMode _BindingUpdateMode = DataSourceUpdateMode.OnPropertyChanged;private ControlUpdateMode _ControlSourceUpdateMode = ControlUpdateMode.OnPropertyChanged;/// <summary>/// The field within the business object that is bound to the control/// </summary>[
Category(BusinessMod.EDITOR_CATEGORY),Description(BusinessMod.EDITOR_BINDINGUPDATEMODE_DESC)]public DataSourceUpdateMode DataSourceUpdateMode{
get{
return this.BindingUpdateMode;}
set{
this.BindingUpdateMode = value;}
}
////not interface methodspublic DataSourceUpdateMode BindingUpdateMode{
get{
return _BindingUpdateMode;}
set{
_BindingUpdateMode =
value;}
}
/// <summary>/// Makes the control available or unavailable for editing/// </summary>/// <value></value>/// <remarks></remarks>[
Browsable(false)]public bool BindingEditable{
get{
return this.Enabled;}
set{
this.Enabled = value;}
}
/// <summary>/// The field within the business object that is bound to the control/// </summary>/// <value></value>/// <remarks></remarks>[
Category(BusinessMod.EDITOR_CATEGORY),DefaultValue(""),Description(BusinessMod.EDITOR_BINDINGFIELD_DESC),Editor(MicroFour.StrataFrame.Extensibility.Constants.TE_BindingFieldEditor, typeof(UITypeEditor))]public string BindingField{
get{
return _BindingField;}
set{
_BindingField =
value;}
}
public string BindingFormat{
get{
return _BindingFormat;}
set{
_BindingFormat =
value;}
}
/// <summary>/// The property on this control to which the data is bound./// </summary>/// <value></value>/// <remarks></remarks>[
Category(BusinessMod.EDITOR_CATEGORY),DefaultValue("PrimaryKey"),Description(BusinessMod.EDITOR_BINDINGPROPERTY_DESC),Editor(MicroFour.StrataFrame.Extensibility.Constants.TE_BindingPropertyEditor, typeof(UITypeEditor))]public string BindingProperty{
get{
return _BindingProperty;}
set{
_BindingProperty =
value;}
}
/// <summary>/// The business object that is used to bind the data to this field/// </summary>/// <value></value>/// <remarks></remarks>[
Category(BusinessMod.EDITOR_CATEGORY),DefaultValue(null),Description(BusinessMod.EDITOR_BUSINESSOBJECT_DESC)]public BusinessLayerBase BusinessObject{
get{
return this._BusinessObject;}
set{
//-- If the business object is being removed, then make sure it is no longer boundif ((value == null) && (_BusinessObject != null)){
this._BusinessObject.RemoveFromListOfBoundControls(this);}
if ((!this.DesignMode) && (value != null)){
value.AddToListOfBoundControls(this);}
_BusinessObject = (
BusinessLayer)value;}
}
/// <summary>/// Gets or sets a value that determines whether the control will allow/// its editable state to be managed by the bound business object./// </summary>/// <value></value>/// <returns></returns>/// <remarks></remarks>[
Category(BusinessMod.EDITOR_CATEGORY),Description(BusinessMod.EDITOR_CONTROLUPDATEMODE_DESC)]public System.Windows.Forms.ControlUpdateMode ControlSourceUpdateMode{
get{
return this._ControlSourceUpdateMode;}
set{
this._ControlSourceUpdateMode = value;}
}
/// <summary>/// If True, the control will ignore that auto manage editing state of the business object. The control will not/// be automatically enabled/disabled by the business object./// </summary>/// <value></value>/// <remarks></remarks>[
Category(BusinessMod.EDITOR_CATEGORY),DefaultValue(true),Description(BusinessMod.EDITOR_IGNOREMANAGE_DESC)]public bool IgnoreManageUIReadOnlyState{
get{
return _IgnoreManageUIReadOnlyState;}
set{
_IgnoreManageUIReadOnlyState =
value;}
}
private void ResetControlSourceUpdateMode(){
this._ControlSourceUpdateMode = ControlUpdateMode.OnPropertyChanged;}
private bool ShouldSerializeControlSourceUpdateMode(){
return this._ControlSourceUpdateMode != ControlUpdateMode.OnPropertyChanged;}
/// <summary>/// Determines if the binding update mode property is set to default/// </summary>/// <returns></returns>/// <remarks></remarks>public bool ShouldSerializeBindingUpdateMode(){
return _BindingUpdateMode != DataSourceUpdateMode.OnPropertyChanged;}
/// <summary>/// Resets the binding update mode/// </summary>/// <remarks></remarks>public void ResetBindingUpdateMode(){
_BindingUpdateMode =
DataSourceUpdateMode.OnPropertyChanged;}
#endregion