Changing the value of a custom property programmatically, does not update the control.


Author
Message
George Nentidis
George Nentidis
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 72, Visits: 251
Hi there.

I have a string custom property in a BO which I bind to a MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit.

When setting the value of the property at run-time, with code 

Customer.CustomProperty = "SomeValue";

the control does not show the changed value. Is it something I'm not doing right? BindingUpdateMode and ControlSourceUpdateMode are both OnPropertyChanged.

I have tried this with your DevEx sample application, and does not work there either.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
There are several options here, but the reason is that there is not a native Changed event managing the custom property.  However, you can do several things, you can create a custom event (propnameChanged as EventHandler) that is raised when the value is changed....or just call the Refresh method on the BO:

Customers.Refresh("MyCustomFieldName")

or within the property

Me.Refresh("MyCustomFieldName")

StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If the custom property does not have a backing field within the underlying DataTable, you will need to raise a "Changed" event when the property is set.  The event needs to be an EventHandler and needs to be named PropertyNameChanged where "PropertyName" is the name of your property (i.e. TextChanged on a textbox).  The .NET binding system will then find the event and add a handler to it to determine when to refresh the control.  So:

public event EventHandler CustomPropertyChanged;

protected virtual void OnCustomPropertyChanged(EventArgs e)
{
    if (CustomPropertyChanged != null)
    { CustomPropertyChanged(e); }
}

[all of the necessary attributes]
public string CustomProperty
{
    get { return _customProperty; }
    set
    {
        if (_customProperty != value)
        {
            _customProperty = value;
            OnCustomPropertyChanged(EventArgs.Empty);
        }
    }
}

George Nentidis
George Nentidis
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 72, Visits: 251
Thank you guys.

It's really nice knowing I can count on you...

StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
We help where we can Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search