|
-
Aug 19th, 2008, 07:35 PM
#1
Thread Starter
Junior Member
How to create strongly typed collection without designer?
I'd like to create strongly typed collection for storing data in tables. is it possible?
-
Aug 19th, 2008, 07:46 PM
#2
Re: How to create strongly typed collection without designer?
Creating a strongly-typed collection is easy:
vb.net Code:
Public Class ThingCollection Inherits System.Collections.ObjectModel.Collection(Of Thing) End Class
That's all you need to get all the standard collection functionality. If you need custom behaviour then the Collection(Of T) class provides methods you can override to do that, plus you can add your own members.
That said, I have no idea what you mean by "for storing in tables". If the data is in a collection then what's the table for? Do you mean a database? Do you mean displaying to the user in a grid? Please provide a full and clear description up front in future. One sentence is rarely enough to convey the full picture to people who have no previous idea of what you're trying to achieve.
-
Aug 19th, 2008, 08:12 PM
#3
Thread Starter
Junior Member
Re: How to create strongly typed collection without designer?
I mean collection like DataTable with some collumns, but I want it to be strongly typed. I want to use data from this collection without conversion.
-
Aug 19th, 2008, 08:36 PM
#4
Re: How to create strongly typed collection without designer?
Then all you need is a strongly-typed collection, as I've demonstrated. Your Thing class will have a property for each data item you want to store. Now, I've just used "Thing" and "ThingCollection" as examples. You would name your classes after whatever the items are supposed to represent.
-
Aug 19th, 2008, 09:08 PM
#5
Thread Starter
Junior Member
Re: How to create strongly typed collection without designer?
thanks, i'll try to do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|