Solved

Options for collections class

Posted on 2008-06-23
15
156 Views
Last Modified: 2010-04-24
What options do I have for creating a collection class that is bindable.
For example, something similiar to creating a class like this that inherits
from CollectionBase
 
 Public Class CustomerList
        Inherits CollectionBase
  End Class

Could I create a custom class that inherits from a Generic list?
0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 3
15 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21849061
Something like the BindingList<T> generics list?
0
 
LVL 8

Author Comment

by:JRockFL
ID: 21849185
Where is bindinglist located? i cant seem to find it?
What's the difference between binding list and list?

I wanted to have a standalone class for each object
For example, something like this... but I have not seen it down with generics..

Imports System.Collections.Generic
Public Class CustomerList
    Inherits List(Of Customer)
End Class
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21849206
Inherit System.Collections.CollectionBase
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21849215
There are a few more complete options in System.Collection.ObjectModel you might look at as well.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21849271
With System.ComponentModel.BindingList<T>, you don't need a custom class:

Imports System.ComponentModel

...

Private m_customerList As New BindingList(Of Employee)
0
 
LVL 8

Author Comment

by:JRockFL
ID: 21849374
How can I manage all of my collections?
I didn't want to have my user class returning a list of itself..
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21849395
You should be defining the collections of class instances outside of the class itself.  Usage really depends on how you are intending to use the lists.
0
 
LVL 8

Author Comment

by:JRockFL
ID: 21849450
So what it make sense to have something like this?

Imports System.ComponentModel
Public Class Collections

Private m_customerList As New BindingList(Of Customer)
Private m_productList As New BindingList(Of Product)

...etc
End Class
0
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 250 total points
ID: 21849513
The point of BindingList is to save you work.  Before .Net or generics you would have had to create your own classes for customer and product collections, and pass around instances of those types.  You'd probably name them CustomerCollection and ProductCollection, and indeed there are a smattering of those custom types still in the base class library.

Now, you don't need to create those types at all.  All the work is done for your.  CustomerCollection and ProductCollection don't need to exist as types.  Just create a BindingList<Customer> when you need one instead.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 21849521
That makes sense on the surface, but where are you going to use those lists?

Are you going to do something like this?

So what it make sense to have something like this?

Imports System.ComponentModel

Public Class Collections

Private m_customerList As New BindingList(Of Customer)
Private m_productList As New BindingList(Of Product)

Public ReadOnly Property CustomerList As BindingList(Of Customer)
  Get
     Return m_customerList
  End Get
End Property

Public ReadOnly Property ProductList As BindingList(Of Product)
  Get
     Return m_productList
  End Get
End Property

End Class
0
 
LVL 8

Author Comment

by:JRockFL
ID: 21849651
jcoehoorn:,
Ok, I see what you are saying now.

TheLearnedOne:
I may to return certain customer objects
WHERE CustomerState = 'AZ'

OR WHERE ProductPrice > 20.00
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21849672
Are you using 3.5 or 2.0?
0
 
LVL 8

Author Comment

by:JRockFL
ID: 21849704
Both! :)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21849727
Are you trying to accomplish in 2.0, what you can do with LINQ in 3.5?
0
 
LVL 8

Author Closing Comment

by:JRockFL
ID: 31469890
Thank you very much, you both have helped.
I'm actually  making my own little code generator, but should probably look into LINQ. Most of the web sites I work on are in 1.1 and 2.0
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question