472,780 Members | 1,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Class derived from PropertyDescriptor

Hello group!

I've created a collection class that implements ITypedList:

class MyCollection : IBindingList, IList, ICollection, IEnumerable, ITypedList
{
PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors)
{
PropertyDescriptorCollection props = new PropertyDescriptorCollection(null);

// Here I add items of type MyPropertyDescriptor to the props collection
props.Add(new MyPropertyDescriptor("Property1"));
props.Add(new MyPropertyDescriptor("Property2"));
props.Add(new MyPropertyDescriptor("PropertyN"));

return props;
}
}

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

// Here I override some methods and properties.

public override string DisplayName
{
get
{
string displayName = string.Empty;

switch(this.Name)
{
case "Property1":
displayName = "My Custom Text 1";
break;
case "Property2":
displayName = "My Custom Text 2";
break;
case "PropertyN":
displayName = "My Custom Text N";
break;
}

return displayName;
}
}

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

public void SetValue(object component, object value)
{
component.GetType().GetProperty(this.Name).SetValu e(component, value, null);
}
}

Everything works fine, all the overriden methods are invoked well, except for the overriden property DisplayName, if I set a break point inside the property, the debuger never stops there.
When I bind my collection to a DataGrid control, the columns are shown in the perfect order (1, 2, N), but they have the property name instead of my custom text.

I'd really appreaciate any help...

Thank you all...
Nov 16 '05 #1
0 4283

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

Similar topics

2
by: S.Sigal | last post by:
Hello: I've seen code in some books for databinding that handles attaching Attributes to Properties during runtime...which is very close (but no cigar) to what I am looking for... The code...
4
by: Julia | last post by:
class Document { Hashtable Properties ; //Key is the property name } class Media { Document document;
2
by: raymi | last post by:
Hi, I have a custom class that gets its properties dynamically from a database at runtime. Therefore I implemented the ICustomTypeDescriptor in this class and created a a custom...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
1
by: machinesofgod | last post by:
Hi, I have a class that implements the ICollection interface and subclasses the PropertyDescriptor class. The problem is that both the interface and base class are expecting an implementation of...
3
by: Michael Chambers | last post by:
Hi there, Is there a clean way to change a property or method's attribute in a derived class without redefining the property/method itself. That is, redefining the property/method in the derived...
5
by: John Wright | last post by:
I want to create a method in my class where I can pass in a property name and have it reset the property to the previous value. I have the method that stores the properties last value, now I need...
11
by: colin | last post by:
Hi, Ive written a custom PropertyDescriptor wich lets me edit my custom data items in the property editor, however I now wish to expand it so that it can be used to edit nested collections of...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.