473,461 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make a stonglytyped collection (to bind)

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)?


Nov 23 '05 #1
3 1332
I inherit from CollectionBase...
--
--Eric Cathell, MCSA
"Michael Fällgreen" <mf*@ulle.se> wrote in message
news:uu****************@tk2msftngp13.phx.gbl...
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)?

Nov 23 '05 #2
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/archi...llections.aspx

http://blogs.msdn.com/kcwalina/archi...26/474010.aspx

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Michael Fällgreen" <mf*@ulle.se> wrote in message
news:uu****************@tk2msftngp13.phx.gbl...
| 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)?
|
|
|
|
Nov 23 '05 #3
Helps a lot - thanks

Michael

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> skrev i en
meddelelse news:ud*************@TK2MSFTNGP15.phx.gbl...
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/archi...llections.aspx

http://blogs.msdn.com/kcwalina/archi...26/474010.aspx

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Michael Fällgreen" <mf*@ulle.se> wrote in message
news:uu****************@tk2msftngp13.phx.gbl...
| 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)?
|
|
|
|

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marc L'Ecuyer | last post by:
Hi, I have a collection class derived from CollectionBase. This collection can add items of my class MyItem. In my class MyItem, I have a Selected property. When this property is set to true, I...
3
by: Nak | last post by:
Hi there, I am trying to make a collection that will work in the "Object collection editor" dialog. I have implimeneted ICollection, IList and IEnumerable and now I have an "unnamed"...
2
by: COHENMARVIN | last post by:
I'm leafing through a big book on asp.net, and I don't see any way to the following: 1. bind values and text to a dropdown 2. Also make the first line of the dropdown say something different. For...
6
by: chriske | last post by:
I'm a newbee student at VB.net so bear with me, is it possible to make a collection from a tabpage inside the tabcontrol so that I can make a new instance containing all the labels and textboxes...
3
by: Locke Nash Cole | last post by:
I've made my first collection. Its a simple one but it works. Now I want to populate a treeview from my collection to display to the user, easy enough... But now comes my dilemma.. say I add a...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
14
by: Jeff S. | last post by:
In a Windows Forms application I plan to have a collection of structs - each of which contains a bunch of properties describing a person (e.g., LastName, FirstName, EmployeeID, HomeAddress,...
1
by: Øyvind Isaksen | last post by:
I try to make my own ArticleAttribute object and ArticleAttributeCollection, and add data to this Collection. It almost works, but the problem is that each time I add an ArticleAttribute to my...
1
by: Rob Meade | last post by:
Hi all, I have my own collection own which implements ienumerable and ienumator. I was recently using a GridView and I was prompted that I could not turn on paging because the data source (my...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.