473,503 Members | 13,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PropertyGrid and property names

Consider the following simple class:

Public Class SomeClass
Private _AnInteger As Integer

Public Property AnInteger As Integer
Get
Return _AnInteger
End Get
Set(Value As Integer)
_AnInteger = Value
End Set
End Property
End Class
If I use the PropertyGrid to display an object of this type, the property
is displayed as "AnInteger". I would like to make the property appear
with alternate text for the property name, but still map to the right
property.

For example, I would like the property in the grid to read "My Integer
Value" (note that I've included spaces) instead of "AnInteger".

Is there any way to make the property grid do this? Or does anyone know of
a control that could do this?

Perhaps what I'm looking for is an attribute that could be applied to the
property to change the display of the grid. But I could not find any.

Thanks,
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #1
1 1362
On Mon, 16 Aug 2004 10:02:44 -0500, Chris Dunaway wrote:

For the benefit of those seeking an answer to this question, I found the
solution.

The steps I followed are:

1. Create an attribute class (inherited from Attribute) for the
DisplayName

2. Create a class that inherits from PropertyDescriptor and override the
DisplayName property to return what you want to appear in the PropertyGrid

3. Create a class that implements the ICustomTypeDescriptor interface.
Implement the GetProperties functions to return a
PropertyDescriptorCollection with instances of the class defined in step 2.

4. Finally, create the class you want to display in the PropertyGrid and
make sure it inherits from the class defined in step 3 above. You can also
combine steps 3 and 4 by by just implementing the ICustomTypeDescriptor
interface in your class.

When you assign an instance of that class to the SelectedObject property of
the PropertyGrid, the grid will show your custom property names.

If anyone wants the code that I used, I will be happy to let them have it.

The following article helped me immensely:

http://www.codeproject.com/cs/miscct...opertygrid.asp

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #2

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

Similar topics

3
2682
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array...
3
2807
by: Lance | last post by:
I have a situation where I want to show a property when one object is selected in a PropertyGrid, but I want to hide that property when more than one object is selected. For example, lets say I have...
2
1615
by: Tugrul HELVACI | last post by:
I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String; fPersonSurName : String; fPersonAge : Integer; published property PersonName : String...
4
3280
by: Tugrul HELVACI | last post by:
Changing DisplayNames of my properties using PropertyGrid component, how ?? I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String;...
0
7098
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
7296
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
7364
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
7017
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
7470
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
5604
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
4696
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
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
405
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.