473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ICustomTypeDescriptor Implementation

Hi all
I'm trying to make the properties of my classes show in the PropertyGrid
with a displayname that it gets from an attribute on the property instead of
showing the actual property name.

Therefore I'm trying to make my class implement the ICustomTypeDescriptor
interface so I can make my own GetProperties method.
I have constructed my own derived PropertyDescriptor class which I try to
use istead of the default propertydescriptor class. This consists of an
overridden displayname property and the Base Property to get to the rest of
the info on the property.
Public Class GBPropertyDescriptor

Inherits System.ComponentModel.PropertyDescriptor

Private _DisplayName As String
Private _BaseProperty As System.ComponentModel.PropertyDescriptor

Public Sub New(ByVal BaseProperty As
System.ComponentModel.PropertyDescriptor, ByVal Name As String, ByVal
DisplayName As String, ByVal Attrs() As System.Attribute)

MyBase.new(Name, Attrs)
Me._BaseProperty = BaseProperty
Me._DisplayName = DisplayName

End Sub

Public Overrides ReadOnly Property DisplayName() As String
Get
Return Me._DisplayName
End Get
End Property

.........
.........

End Class

I'm not shure if I have this class right, but my main problem i s the
GetProperties method itself:
I need to get the base PropertyDescriptors of the class so I can pass this
to the constructor of my derived PropertyDescriptor class.

something like This (Code is cinstructed by intuition not tested) :

Public Function GetProperties(ByVal attributes() As System.Attribute) As
System.ComponentModel.PropertyDescriptorCollection Implements
System.ComponentModel.ICustomTypeDescriptor.GetPro perties

Dim properties As System.ComponentModel.PropertyDescriptorCollection
Dim prop As System.ComponentModel.PropertyDescriptor
Dim NewPropertyDescriptor As GBPropertyDescriptor
Dim MyPropertyCollection As ArrayList
Dim PropArray As System.ComponentModel.PropertyDescriptor()

properties = 'thisclass.GetTheREalProperties' <------ THIS IS THE REAL
PROBLEM

For Each prop In properties
NewPropertyDescriptor = New GBPropertyDescriptor(prop, "RealName",
"DisplayName", attributes)
MyPropertyCollection.Add(NewPropertyDescriptor)
Next

PropArray = MyPropertyCollection.ToArray
Return New PropertyDescriptorCollection(PropArray)

End Function
But how do I get the "Real" properties when I have just overridden the
method that get's them ??
Does anyone have some example code that can clear things up for me ? I feel
that I'm very close, but just can't get it right.

Thanks in advance
Allan Bredahl
Jul 19 '05 #1
0 6031

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

Similar topics

9
4617
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
0
362
by: Allan Bredahl | last post by:
Hi all I'm trying to make the properties of my classes show in the PropertyGrid with a displayname that it gets from an attribute on the property instead of showing the actual property name. ...
29
2218
by: Enrico `Trippo' Porreca | last post by:
Both K&R book and Steve Summit's tutorial define a getline() function correctly testing the return value of getchar() against EOF. I know that getchar() returns EOF or the character value cast to...
2
1385
by: Julia | last post by:
Hi, After implementing ICustomTypeDescriptor on my UserControl When ever I drop the control it moved to the none visual area Which properties or attributes should I add to my Descriptors...
52
3696
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
20
6045
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
0
1980
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
2763
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
173
13766
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
7260
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
7162
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
7527
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
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,...
1
5090
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1597
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 ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.