How to make a stonglytyped collection (to bind)

  • Thread starter Michael Fällgreen
  • Start date
M

Michael Fällgreen

Hi,

I need to make a strongly typed collection of x, and the simplets way is to
inherits list(of x). With that I can bind to a list-control. However - i
don't need all the methods from list(of x).

If I make a private list as list(of x) in a class and implements IList(of x)
I can control what methods to be public. I works - but now I can't bind the
collection to a listbox og grid (it says something about complex datatype).

What is the right way of doing a strongly typed collection (that can bind to
a ui control)?
 
J

Jay B. Harlow [MVP - Outlook]

Michael,
In VB 2005: Rather then inheriting directly from
System.Collections.Generics.List(Of T) I would recommend inheriting from
System.Collections.ObjectModel.Collection(Of T).

In VB 2002 & 2003: I would use CollectionBase as ECathell suggests.

As Collection(Of T) is the Generics replacement for CollectionBase, while
KeyedCollection(Of K, T) is the Generics "replacement" for DictionaryBase.

http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx

http://blogs.msdn.com/kcwalina/archive/2005/09/26/474010.aspx

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Hi,
|
| I need to make a strongly typed collection of x, and the simplets way is
to
| inherits list(of x). With that I can bind to a list-control. However - i
| don't need all the methods from list(of x).
|
| If I make a private list as list(of x) in a class and implements IList(of
x)
| I can control what methods to be public. I works - but now I can't bind
the
| collection to a listbox og grid (it says something about complex
datatype).
|
| What is the right way of doing a strongly typed collection (that can bind
to
| a ui control)?
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top