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 / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

BindingListOfT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Veeneman - 27 Dec 2005 12:43 GMT
I'm using the new BindingList generic class in a collection class. For those
not familiar with BindingLists, they are similar to generic ArrayLists, but
they implement the IBindingList interface, which means they support two-way
data binding.

As my class is written, the collection's BindingList is exposed as a
property. That means I have to bind to the property, rather than the
collection, like this:

dataGridView1.DataSource = myCollection.BindingList;

I'd rather bind directly to the collection, rather than to a property, like
this:

dataGridView1.DataSource = myCollection;

Is there a way to accomplish this with a BindingList? Or, is there a base
class that implements IBindingList that I could derive from? Thanks in
advance for your help.

David Veeneman
Foresight Systems
Bart Mermuys - 27 Dec 2005 17:08 GMT
Hi,

> I'm using the new BindingList generic class in a collection class. For
> those not familiar with BindingLists, they are similar to generic
[quoted text clipped - 14 lines]
> Is there a way to accomplish this with a BindingList? Or, is there a base
> class that implements IBindingList that I could derive from?

Maybe i'm missing something but you can derive from BindingList<T>, eg:

public class PersonCollection : BindingList<Person>
{
}

HTH,
Greetings

Thanks in
> advance for your help.
>
> David Veeneman
> Foresight Systems
David Veeneman - 27 Dec 2005 18:43 GMT
So simple, I completely overlooked it! Thanks.
Michael S - 29 Dec 2005 01:44 GMT
> So simple, I completely overlooked it! Thanks.

Yep.

Inheritance is somewhat hard to grasp for some. Generics often more so. We
all master them some day and know the idioms and their use, and when not to.
But combined they make for some serious braindamage when thinking on how to
solve stuff, while the solution often turn out to be quite simple..

I was lost at this one and was about to submit a 'it can't be done' post
when I saw the solution...

All too easy..

Happy Coding
- Michael S
W.Meints - 27 Dec 2005 19:27 GMT
Hi David,

Assuming you have implemented a custom collection to keep track of your data.
You can replace the collection with a declaration like this:

BindingList<Person> persons = new BindingList<Person>();

And bind it to the datagridview

DataGridView1.DataSource = persons;
Signature

Best regards,

W.Meints

> Hi,
>
[quoted text clipped - 31 lines]
> > David Veeneman
> > Foresight Systems

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.