Property Name

simonbesner

New member
Joined
Aug 18, 2009
Messages
2
Programming Experience
5-10
Hello everyone,

Recently, I did buy a PropertyGrid component. There's only one problem with this component: to add a property, it requires an objet instance (this is ok) AND the property name as a text parameter (this is the problem).

When you build the grid the first time there's no problem with this. You would get something like this:

propertyGrid1.AddProperty(myInstance, "PropertyName1")
propertyGrid1.AddProperty(myInstance, "PropertyName2")
...

However, if you rename or remove a property used by the property grid component, there's no way to be notified at design time.

Could it be possible to create something like this:
propertyGrid1.AddProperty(myInstance, myInstance.Property1.GetPropertyName)

This way, if the property1 is renamed or deleted, VS will list it as an error.

Does someone have a solution?

Regards

Simon

P.S. Someone told me that Lambda Expression could help me... I don't know much about the lambda expression and there's only few example written in VB.
 
Hi Robert,

The main point here is not to get the properties names... it's to get notified by the compiler if a property is deleted or renamed.

This morning I did find a solution using the lambda expression. It's doing exactly what I want (even if I think the lambda expression are realy complex).

I'm still wondering if there's a more simple way to do this.
 
Back
Top