473,412 Members | 3,471 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,412 software developers and data experts.

Implementing ITypedList

Hello group!

I got a little question for you all...

I've created two classes (FirstCollection and SecondCollection) that implements some interfaces: IBindingList, IList, ICollection, IEnumerable and ITypedList.
In my FirstCollection class, the method ITypedList.GetItemProperties(..) returns a PropertyDescriptorCollection object, so I've created a class MyFirstItemPropertyDescriptor that derives from PropertyDescriptor.
I'll show you a little bit of code:

class MyFirstItemPropertyDescriptor : PropertyDescriptor
{
public MyFirstItemPropertyDescriptor(string propertyName) : base(propertyName, null)
{
}

public override System.Type ComponentType
{
get { return typeof(MyFirstItem); }
}

public override System.Type PropertyType
{
get
{
Type type = null;

switch(this.Name)
{
case "Column1":
type = typeof(string);
break;

case "Column2":
type = typeof(int);
break;

case "ChildItems":
type = typeof(IBindingList);
break;
}

return type;
}

public override object GetValue(object component)
{
return component.GetType().GetProperty(this.Name).GetValu e(component, null);
}
}
}

For the ITypedList implementation in my SecondCollection class I've created a class named MySecondItemPropertyDescriptor derived from PropertyDescriptor too.
Besides, both MyFirstItem and MySecondItem classes implement the ICustomTypeDescritor interface and the method ICustomTypeDescriptor.GetProperties(..) returns the same PropertyDescriptorCollection object returned by the container collection in its method ITypedList.GetItemProperties(..).
I want each item in my FirstCollection object to have a property that stores a SecondCollection object (like DataRowView objects (contained in DataView objects) that have other DataView object associated).
When I test my FirstCollection object as a DataSource for the DataGrid control, I can edit each column coming from the PropertyDescriptorCollection returned by the ITypedList interface, and I can even see a plus icon in the left side of each row, and when I expand it I can see some kind of "hyperlink" with the name of my SecondCollection object.
The problem arises when I click the "hyperlink"; the DataGrid control tries to edit a MySecondItem object, but keeping the columns of the MyFirstItem objects and an exception of type System.Reflection.TargetException is thrown.

I'm developing an important project so I will really appreciate any help...

Thank you all...
Jul 21 '05 #1
0 1211

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

Similar topics

4
by: Frank J. Reashore | last post by:
Hello Everyone, I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a method on the interface is not...
0
by: Alx Sharp | last post by:
Hello group! I got a little question for you all... I've created two classes (FirstCollection and SecondCollection) that implements some interfaces: IBindingList, IList, ICollection,...
1
by: Joe Jax | last post by:
I'm building my own version of a readonly DataTable, which needs to bind to various controls. My data table class has two main collections (CollectionBase instances): one of columns, one of rows,...
7
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
11
by: Norbert Ruessmann | last post by:
Hello group, I have a problem with ObjectDataSource and ITypedList. At the end of this entry you find the implementatiopn of my List class, derived from ArrayList and implementing ITypedList....
6
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer {...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
2
by: Ian Semmel | last post by:
I am new to this world of ASP.NET so forgive the dumb questions. I have been looking at the sample provided 'Implementing a Session-State Store Provider' in an effort to understand how the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.