Hi Phil,
> Here's my situation: We are building a windows form app, and we are not
> using DataSets. I have various business entities, and custom collections
What is it about the DataSet class that doesn't meet the needs of your app?
Business objects should contain business logic routines and provide
intuitive interfaces for other components and DataSets can be used to manage
the underlying business data. Without DataSets you lose out on so much.
> What I would like to do is to create a hierarchy of these business
> entities.
[quoted text clipped - 4 lines]
> their relations from the database, and then pass them to the UI which will
> then databind to it
Strong-Typed DataSets do all of this out-of-the-box and more. I suggest
thoroughly researching DataSets before attempting to recreate their
functionality in custom code.
> I'm curious as to what interfaces I need to implement to ensure that I can
> databind in a way that will allow the UI to view the hierarchy of entities
> w/o having to actually parse the tree and insert the appropriate nodes.
> I've
> yet to see an example. Can anyone point me in the right direction?
In .NET 2.0 use the BindingSource class to wrap your business object and
bind controls to the BindingSource class. BindingSource will allow controls
to bind to the public properties of your object. Using BindingSource hides
the complexities in implementing IBindingList, an interface that an object
exposes when it supplies an IList for binding. In previous framework
versions you'll need to implement ICollection on your collections or
IBindingList for a more complex binding architecture.
HTH
Grant Frisken - 05 Jul 2006 05:55 GMT
If you don't want to use DataSets you don't have to give up data
binding but you do, as Dave, pointed out have to implement certain
interfaces on your collections (in particular IBindingList) to take
full advantage of two way data binding (where the data source notifies
client controls when it is changed allowing the controls to update
automatically).
Most tree/grid controls don't handle binding to arbitrary hierarchical
data sources. You might want to take a look at Infralutions Virtual
Tree control which is designed for this type of scenario
Regards
Grant Frisken
Infralution
www.infralution.com
> Hi Phil,
>
[quoted text clipped - 34 lines]
>
> HTH
PMarino - 10 Jul 2006 14:45 GMT
Thanks to both of you who replied. I'm not completely finished, but I have a
good start.
I can't switch to datasets now - we're too far along in the course of our
project. However, using Generics, I came up with the start of a workable
solution.
I haven't implemented IBindingList yet, but I did implement ITypedList. I
also used Generics to create a PropertyDescriptor that's basically a wrapper
for the actual PropertyDescriptor of the contained entity. This works pretty
well.
Thanks,
Phil
> If you don't want to use DataSets you don't have to give up data
> binding but you do, as Dave, pointed out have to implement certain
[quoted text clipped - 50 lines]
> >
> > HTH