Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

How to Force Push/Pull on Bound Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
darndt - 27 Jan 2005 16:15 GMT
How can I force my form to re-read fields from the bound object?

In my case, I have a form that uses simple binding to bind to properties on
an object. I'm using the Format/Parse events to manage data flow in/out of
the object. Everything works very well.

Sometimes, I want to trigger the form to re-read (get properties) from the
object (i.e., the object receives data from an underlying socket connection).
If I fire an event to let the form (view) know that the object (model) has
changed, how can I tell the form to re-read properties from the object?
darndt - 27 Jan 2005 17:19 GMT
Found a solution for this searching in this forum:

"""""
Get the underlying PropertyManager and call ResumeBinding.  It calls the
protected OnCurrentChanged() method which calls the protected PushData()
method.

private void RefreshObjectBinding(object obj)
{
   PropertyManager pm = (PropertyManager)BindingContext[obj];
   pm.ResumeBinding();
}

Cole
"""""

This works quite well.
Neil Allen - 28 Jan 2005 09:33 GMT
>How can I force my form to re-read fields from the bound object?
>
[quoted text clipped - 6 lines]
>If I fire an event to let the form (view) know that the object (model) has
>changed, how can I tell the form to re-read properties from the object?

Dear "darndt"

If I understand the problem correctly then it might be easier to
implement XXXChanged events for each property of the "bound object".

Here's a similar situation...

http://www.google.co.uk/groups?hl=en&lr=&selm=1402p0th0d30fem53usgocg8j3qf4p5fpm
%404ax.com


Hope this helps

regards

Neil Allen
darndt - 28 Jan 2005 12:07 GMT
> Dear "darndt"
>
[quoted text clipped - 4 lines]
>
> http://www.google.co.uk/groups?hl=en&lr=&selm=1402p0th0d30fem53usgocg8j3qf4p5fpm
%404ax.com

Neil,

Yes - that's the other side of the equation.   We're implementing a
light-weight model-viewer pattern here.   So the models will fire events when
they change - but when they do, the view needs to be able to force a re-read
from the model.  

I was looking for a way to force the data-bindings to "get" (re-read) their
respective properties.  Using the "ResumeBinding()" call on the
BindingManager accomplishes this.

Thanks,

-- Dave
Neil Allen - 28 Jan 2005 16:53 GMT
>> Dear "darndt"
>>
[quoted text clipped - 19 lines]
>
>-- Dave

Dear Dave

I'm probably a bit too old to get the hang of the "model-viewer
pattern" but it does sound like you have an object (the model?) that
is bound to a Windows Forms control or controls (the viewer?).

So when you say "So the models will fire events when
they change - but when they do, the view needs to be able to force a
re-read from the model." it really does sound like you want the
controls on the form to show the data from the bound object when the
data in the object changes. In which case implementing the changed
events in the bound object will "automatically" perform the call to
the get accessors of the bound object.

My apologies if I've got hold of the wrong end of the stick.

Regards

Neil Allen

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.