Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Correctly displaying IDictionary derived class in PropertyGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marek - 31 Aug 2006 13:08 GMT
Hi
I have a class which has a property which implements IDictionary which I
would like to display in a propertygrid control.  If I add
[TypeConverter(typeof(ExpandableObjectConverter))] the property expands, but
I only get Count, IsReadOnly, Keys and Values properties, all of which are
disabled.

If I implement my property as Dictionary<string, myObj> I get the option to
click on the keys and the values, but these then bring up the input dialog
into which I can't add any new values (for good reason).

List<myObj> works fine of course.

I have googled around and found some articles, but none of these seemed to
work.

Please could anyone advise as to the best way to solve this problem.

Marek
Stoitcho Goutsev (100) - 31 Aug 2006 14:48 GMT
Marek,

What was the question. I kind of missed it. What is that you want to
achieve?

Signature

Stoitcho Goutsev (100)

> Hi
> I have a class which has a property which implements IDictionary which I
[quoted text clipped - 17 lines]
>
> Marek
Marek - 31 Aug 2006 15:03 GMT
Hi Stoitcho
Sorry for the confusion, it's a bit hard to get my requirements down on paper!

The question is how to display an object's property (called MyCollection
say) where the MyCollection property is a class implemented as follows:

class MyCollectionClass : IDictionary<string, MyObjectType>

so that when the object is displayed in the property grid the user can
expand the MyCollection property with say an ellipsis button and then add and
remove objects of the type specified by IDictionary<key, MyObjectType> and
set their values in a manner similar to that had I used List<MyObjectType>
for example.

My current line of attack is as follows:

[Editor(typeof(MyCollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]
       public MyCollectionClass

and then in MyCollectionEditor to the override GetEditStyle and EditValue
and to display a custom form which allows the user to edit the collection and
its contents.  The second question therefore is is this approach the right
one in a .NET2 world?

I hope this makes sense.

Marek

> Marek,
>
[quoted text clipped - 22 lines]
> >
> > Marek
Stoitcho Goutsev (100) - 31 Aug 2006 15:49 GMT
Marek,

Have you seen this somewhere in the standard framework controls? If you have
then you can try with the reflector to find out what type of editor
micorosoft guys use. Sometimes it is possible to reuse their. If there is
nothing out of the box I'm afraid you need to write your own as you've
already started.

Signature

Stoitcho Goutsev (100)

> Hi Stoitcho
> Sorry for the confusion, it's a bit hard to get my requirements down on
[quoted text clipped - 60 lines]
>> >
>> > Marek

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.