RE: Small error in Code

It's not really so much a bug in the code as it is a gap in the functionality. I've got to ask why you're putting nulls into a dictionary that you then intend to put into a PropertyGrid. Even if this was your desired functionality, using typeof(object) might not be the right answer either. Consider the following (using System.Net.Mail):

dict["To"] = new MailAddress("somebody@example.com");

versus the following:

dict["To"] = null;

It could be argued that the correct behaviour in the second instance is to present the user with a MailAddress that can be edited, rather than a System.Object that makes no sense.

So, it's up to you how to solve it. I decided to opt for disallowing it. In another project, I invented an ExtendedDictionary class that also held categories and descriptions for display in the PropertyGrid. It would be possible to hold the type as well.

Cheers,
Roger.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <br> <code> <dd> <dl> <dt> <hr> <h1> <h2> <h3> <i> <img> <li> <ol> <p> <pre> <table> <td> <th> <tr> <tt> <u> <ul>
  • Images can be added to this post.

More information about formatting options