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!