Data Binding NON-UI objects?

M

matty.hall

There's a lot of information out there about data-binding UI objects
(i.e. derived from Control) to non-UI custom business objects. Is it
possible to do the same without any UI being involved at all?

Here's an example:

I want to do data binding on some of the properties of a TreeNode
(namely its Name). Unfortunately, TreeNode does not derive from
Control, so it doesn't have the "stock" data binding stuff. I'd like
to create a new class that derives from TreeNode that reimplments this
data binding stuff.

I tried to create a PropertyManager and simply add data bindings to it,
but unfortunately the PropertyManager's DataBindings collection is
read-only. Is there anyway to accomplish something like this?

Although this question is specifically about TreeNode, I guess I'm
wondering about the more general question: how do I go about adding a
binding manager to a custom business object to give it binding support
like controls have?
 
N

Nicholas Paldino [.NET/C# MVP]

Matty,

Are you able to use .NET 2.0? If so, you can use the implement the
IBindableComponent interface, which will allow you to pass your control to
the ControlBindingsCollection (exposed by the DataBindings property on
controls, and on your class), and allow it to be data bound.

Hope this helps.
 

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