473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Custom Collections

Hello!

I defined a custom collection class that inherits from CollectionBase, it
works fine...

Now, I would like to add each item an ID property, so I could access items
in the collection by ID. What I need is a sample how I can generate unique
ID each time when a new Item is added to the collection?

Thanks!

James
Nov 19 '05 #1
2 930
How about running a int TotalItemAdded private field?

private int TotalItemsAdded

public Add( object o )
{
o.ID = "item_" + TotalItemsAdded.ToString();
//Add item
TotalItemsAdded++;
}

Note that nothing decrements TotalItemsAdded.

bill

"James T." <gi*****@hotmail.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
Hello!

I defined a custom collection class that inherits from CollectionBase, it
works fine...

Now, I would like to add each item an ID property, so I could access items
in the collection by ID. What I need is a sample how I can generate unique
ID each time when a new Item is added to the collection?

Thanks!

James

Nov 19 '05 #2
On Tue, 26 Apr 2005 13:57:22 +0300 in
microsoft.public.dotnet.framework.aspnet, "James T."
<gi*****@hotmail.com> wrote:
Hello!

I defined a custom collection class that inherits from CollectionBase, it
works fine...

Now, I would like to add each item an ID property, so I could access items
in the collection by ID. What I need is a sample how I can generate unique
ID each time when a new Item is added to the collection?


Guid guidID = Guid.NewGuid();

Roger

Nov 19 '05 #3

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

Similar topics

9
by: craig | last post by:
Assume that you would like to create a custom collection class that is: 1. Strongly-typed (only holds Customer objects) 2. Read-only (user cannot add Customer objects) 3. Able to be bound to...
3
by: JimGreen | last post by:
We are designing a WinForm application ( three tiered) There is a debate in our group as to whether we should pass datasets or our custom collections from business layer to the user interface...
0
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and...
6
by: kbs | last post by:
Hi, I'm looking for some good examples that illustrate how to code a web service that exposes a custom collection so that the properties of the collection are accessible on the client without...
4
by: John Dalberg | last post by:
I noticed the starterkits timetracker & issue tracker load data from a database into custom collections (arraylists) which bind to a datagrid. What are the advantages of using custom collections...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
0
by: Rajesh | last post by:
I am trying to use a simple custom type for saving the profile information of a user. The custom class inherits from the Hashtable. I am serializing the type as "Binary" in the provider sections of...
0
by: w31chang | last post by:
Hi, I create custom entity objects, a custom collections for the entity objects and a custom object that acts like a collection of the custom entity collections which I called EntitySet Object. The...
4
balabaster
by: balabaster | last post by:
Okay, I decided that I needed to understand the whole custom configuration file bits and so I've spent some time playing around with it. It seems (in the most) relatively straight forward. However,...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.