473,466 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CollectionBase IBindingList confliction problems

I have a collection class that inherits from CollectionBase, and
implements IBindingList, and I'm having problems with recursion or List
not having an instance.

This is a simple version of the class.

public class MyCollection : CollectionBase, IBindingList
{
public int Add( object value )
{
return this.List.Add( value );
}
}

This causes an infinite loop when trying to add to the collection, and
I think it's because IBindingList implements IList, so it keeps calling
itself.

So I pass the actual class object type in instead.

public class MyCollection : CollectionBase, IBindingList
{
public int Add( MyClass value )
{
return this.List.Add( value );
}
}

When I do this, List either will give an error about a null reference,
or it will return void and not add anything to the list.

I've seen this done all over the place, but it doesn't seem to be
working for me.

Am I doing this wrong?

Nov 17 '05 #1
2 2037
Hi,

public class MyCollection : CollectionBase, IBindingList
{
public int Add( object value )
{
return this.List.Add( value );
}
}


I think the correct way is this.InnerList.Add( value)

what is what you expect to return? what that int represent?
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 17 '05 #2
Manipulating everything via innerlist might stop the IList
implementation conflictions.

I'm actually not going to use IBindingList anymore, so I don't need to
worry about it now.

Nov 17 '05 #3

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

Similar topics

5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
7
by: m. pollack | last post by:
Hi all, I've been using the CollectionBase class to implement a strongly-typed collection, but I have noticed that the RemoveAt method does not seem to call the "On" hook methods (OnRemove,...
2
by: m.pollack | last post by:
Hi all, I have an application which uses a class object that contains a collection. In order to use the PropertyGrid control to expose properties to the user at runtime, I created a...
4
by: keith | last post by:
There is an sample class CustomerList to implement the interface IBindingList in MSDN. But it dosen't have codes for followings to show how to sort the collection. Can you provide codes to to...
5
by: Matthew Woods | last post by:
bool A = Is this the right place to ask this question? if (A) { Where can i find a good example of an ArrayList bound to a datagrid that automatically updates the grid when the public data...
3
by: Matthew Woods | last post by:
Hi, is there any way to format and order the columns displayed in a datagrid bound to a class that inherits from IBindingList? i have used DataGridTableStyle and added DataGridTextBoxColumns to it...
3
by: Shannon Richards | last post by:
Can anyone tell me what the CollectionBase.OnSetComplete() overridable method is supposed to be used for? MyCollectionClass(Index) = Object triggers this method but why does "setting" in a...
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: Mr. Clean | last post by:
I have this class: Public Class collBusinessObject Inherits CollectionBase Implements IBindingList Now how do I use the Find function to find a collection item that has a property named ID?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.