How to Force Push/Pull on Bound Object

G

Guest

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?
 
G

Guest

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.
 
N

Neil Allen

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?


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=&[email protected]

Hope this helps

regards

Neil Allen
 
G

Guest

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=&[email protected]

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
 
N

Neil Allen

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


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top