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 / July 2006

Tip: Looking for answers? Try searching our database.

Databindable hierarchical object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PMarino - 02 Jul 2006 06:12 GMT
Hi all - I was wondering what would be the best way to implement a
hierarchical structure so that I can use it in databinding.  

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
(and these collections are bindable).

What I would like to do is to create a hierarchy of these business entities.
I'd like to keep the hierarchical relationships separate from the entities
themselves.  My ideal object will be a Generic, and each instance will
contain only a single entity type.  I would like to retrieve the entities and
their relations from the database, and then pass them to the UI which will
then databind to it.  We're using Infragistics controls, if it matters.

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?

Thanks!
Phil
Dave Sexton - 04 Jul 2006 23:06 GMT
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

Rate this thread:







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.