Questions tagged [collectionbase]

19 questions
10
votes
2 answers

Is the CollectionBase class still supported?

I want to create a class that inherits from CollectionBase, but it seems that it does not support LINQ extensions! Is it still supported? Or is there an alternative solution?
Homam
  • 23,263
  • 32
  • 111
  • 187
5
votes
1 answer

Use AutoMapper with custom conversion on a specific property

Dear Internet community. I need to map elements from one object to another. The classes are identical (same class name, same properties), so I figure we should give AutoMapper a try instead. It seems to work pretty well, but I've hit a snag: One…
Sigurd Garshol
  • 1,376
  • 3
  • 15
  • 36
3
votes
4 answers

How can I get a collection's parent object?

In C#, if I have an object that has a collection, is it possible to retrieve the object that contains the collection? Here is an example: public class TestObject { public string name { get; set; } public TestObjectCollection testObjects{…
Simon
  • 7,991
  • 21
  • 83
  • 163
3
votes
1 answer

How to implement a custom typesafe collection using generic collections?

I used a strongly typed collection that derived from the CollectionBase class and now I'd like to change it to inherit from a typesafe generic collection. Some advise to inherit from List, some do advise to use Collection. What I'd like to do…
1
vote
2 answers

How to tell when somebody is reading an item from a CollectionBase

I'm not sure if this is possible using a CollectionBase class. I'd like to know when somebody is accessing an item in a CollectionBase class. The final goal is to create a "VirtualMode" (similar to the DataGridView control) that allows me to check…
Trevor Watson
  • 415
  • 1
  • 8
  • 20
1
vote
1 answer

Determining type of CollectionBase via Reflections (or Microsoft.Cci)

Question: Is there a static way to reliably determine the type contained by a type derived from CollectionBase, using Reflection or Microsoft.Cci? Background: I am working on a code generator that copies types, makes customized versions of those…
Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
1
vote
1 answer

I receive the following error while trying to get the index of a class that inherits from CollectionBase: Cannot apply indexing with []

I have a class that inherits from CollectionBase. public NavigationMenuItemsCollection MenuItems { get; set; } I have a method that is attempting to get the item from the index, but it's not working. public void ActivatePage(int index) { …
ernest
  • 1,633
  • 2
  • 30
  • 48
1
vote
2 answers

Create a custom list without default methods

I am creating a list derived from CollectionBase, so that I can use my own methods. This is made in a dll project. I just wanted to know if it is possible to hide the default methods from CollectionBase, so that only my methods appear when this list…
user2858325
  • 15
  • 1
  • 4
1
vote
1 answer

Binding to property of a class derived from CollectionBase

I am trying to bind some controls to an object - which is normally a pretty straightforward process. Unfortunately, if the object that I'm binding to inherits from CollectionBase, binding to that classes fields causes the error: Cannot bind to the…
1
vote
3 answers

IList List in collection base class?

question is Regarding the collection base class that implements a weird property: protected IList List { get; } 1) What is Ilist List in collection base class?? ... 2) It is not even initialized ... how can it be accessed then ... 3) When to use…
Sana.91
  • 1,999
  • 4
  • 33
  • 52
0
votes
2 answers

Generic Collection - CollectionBase, IBindingList and Firing Events on Item Changes/Edits

I've implemented a GenericCollection using IBindingList, and it works great and fires events for when items are added or removed. It doesn't fire events when items are changed/edited as expected. Is there a simple way to implement logic to catch a…
mservidio
  • 12,817
  • 9
  • 58
  • 84
0
votes
1 answer

How can I get a list of CollectionBase items?

In C#, if I have a CollectionBase of type T, and each item in the CollectionBase can have a child CollectionBase of the same type T, how can I get a list of all type T objects without using a recursive function? Does LINQ have a feature to do…
Simon
  • 7,991
  • 21
  • 83
  • 163
0
votes
1 answer

How can LINQ actions be performed on a CollectionBase?

I am coding a C# forms application and I have the following collection for a PropertyGrid control: public class CustomWebpageJavaScriptFunctionCollection : CollectionBase, ICustomTypeDescriptor { public void Add(CustomWebpageJavaScriptFunction…
Simon
  • 7,991
  • 21
  • 83
  • 163
0
votes
0 answers

Open file to populate collectionBase?

I'm doing a little project for school and I'm stuck on the fact that they want us to use collectionbase and file handling... My question is what do I need to do on launch of the app to open the .txt file and populate a collectionbase? Is this…
techker
  • 189
  • 1
  • 10
0
votes
1 answer

Its not going to CollectionBase, Enumerator,Enumerable objects

I have a class in the code below, where besides equals and hash methods from IEqualityComparer which I use, I also want to implement add, remove, item, count from list and GetEnumerator (current,movenext,position). So I decided to use Inherits…
unknown
  • 75
  • 7
1
2