In a project in C# (.Net 2.0) I use a propertygrid. This propertygrid displays objects retrieved from a PHP backend via SOAP. Some objects contain string properties where the meaning of an empty string is different compared to the meaning of a string that's NULL. An example of an object returned by a SOAP call might be:
SomeObject {
PropertyA = "Foo"
PropertyB = "Bar"
PropertyC = Null
}
As long as I don't "touch" PropertyC in the PropertyGrid, the value of PropertyC will remain null. When I enter "foobar" as value and then clear the text in the propertygrid for PropertyC the value will equal an empty string. This is all fine by me; the user should be able to "enter" an empty string. But I also want the user to be able to specify a "null" value.
The way I envision this is that the user can Right-click the value of the property and a context-menu will pop-up with a "Clear value" option which would set the value to Null.
Important: I do not want to use a "magic value" like the string "Null" or "Magix123" to specify the value needs to be null. Ofcourse, the backend could interpret these values and store an actual null but this "solution" is, apart from being plain dirty, not wanted because it would require changing a lot of code all over the place handling the "Magic values".
Ideally the PropertyGrid would also display a null value as ("grayed") "" so the user can see the difference between an empty string and a Null value.
Anyone have an idea on how to handle this kind of situation? Does the (.Net 2.0!) PropertyGrid allow me to do this kind of stuff? And how would I have to go about it then? Would I need to create my own usercontrol derived from a PropertyGrid or does the PropertyGrid have some function(s) I missed?