473,325 Members | 2,860 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,325 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 1208

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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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

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.