Wednesday, October 24, 2007

Editing a password in a PropertyGrid control

Sometimes, when something is too simple, you can spend hours to find out the solution. That happened to me yesterday as I was looking for a way to edit a password in a PropertyGrid control. As you should know, the PropertyGrid control can be customized by adding attributes on object's property you want to edit. One of this attribute is "Editor". With this attribute you can define a designer class that inherits from UITypeEditor to implement your own way to edit the value of a field in the property grid. I made some research on internet to find if somebody had build a special editor for password. No luck. Every time I was looking for page with "UITypeEditor and Password" I found many pages talking about UITypeEditor only. These pages were found because they all contain a "Forgot your password" link in it. Then I tied to search on Code Search. Here I found some interesting code that lead me to Enterprise Library, but it turns out to be a dead-end. Finally I used Reflector to search for "Password". This is where I found that simple attribute called "PasswordPropertyTextAttribute". So the solution was only to add this attribute to my password property and that's it!

8 comments:

Anonymous said...

This Blog saved me a lot of time.
Thanks!!!

colegiojuansalvador said...

Thanks a LOT!!!!!

p3rr4kus said...

Thanks, I was looking for this.

Does anyone know where to find all attributes that apply to PropertyGrid?

Riory said...

you are a real time-saver !
TNX (^_^)

Anonymous said...

thx thx thx

Pipalia said...

Thank you - you have saved me hours of unnecessary work!!

Being new to .NET, It took me ages to figure out how to change category within property grid when using My.MySettings - I couldn't find any straight forward article out there, but figure it out in the end and this follows on from there. Thanks again.

Max said...

Searching Google for 'password PropertyGrid' gave me as first result: http://jenswinter.com/post/2005/11/How-to-Passwort-im-PropertyGrid.aspx which is even slightly better than the PasswordPropertyText attribute as it requires you to enter a password verification. It's in German but exmaples are English and Google Translate is your friend...

Best regards, Max

Mike Nakis said...

Thank you for sharing your finding! Saved me some time, too!