Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Options for collections class

Posted on 2008-06-23
15
Medium Priority
?
158 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
  • 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:Joel Coehoorn
ID: 21849206
Inherit System.Collections.CollectionBase
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 18

Expert Comment

by:Joel Coehoorn
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:
Joel Coehoorn earned 1000 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline
Suggested Courses

824 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