StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Changing the value of a custom property...Expand / Collapse
Author
Message
Posted 01/28/2008 6:01:59 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 05/30/2008 10:52:28 AM
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.

Post #13763
Posted 01/28/2008 10:04:57 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 8:12:17 AM
Posts: 4,243, Visits: 4,288
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")
Post #13769
Posted 01/28/2008 10:09:25 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 9:05:01 AM
Posts: 2,666, Visits: 1,878
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);
        }
    }
}


www.bungie.net
Post #13770
Posted 01/29/2008 10:42:52 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 05/30/2008 10:52:28 AM
Posts: 72, Visits: 251
Thank you guys.

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

Post #13828
Posted 01/29/2008 11:43:29 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 9:05:01 AM
Posts: 2,666, Visits: 1,878
We help where we can


www.bungie.net
Post #13830
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 9:21am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 11 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.