PC Review


Reply
Thread Tools Rate Thread

Correctly displaying IDictionary derived class in PropertyGrid

 
 
=?Utf-8?B?TWFyZWs=?=
Guest
Posts: n/a
 
      31st Aug 2006
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
 
Reply With Quote
 
 
 
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      31st Aug 2006
Marek,

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


--
Stoitcho Goutsev (100)

"Marek" <(E-Mail Removed)> wrote in message
news:CC464D8A-03CA-45A0-B35F-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?TWFyZWs=?=
Guest
Posts: n/a
 
      31st Aug 2006
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

"Stoitcho Goutsev (100)" wrote:

> Marek,
>
> What was the question. I kind of missed it. What is that you want to
> achieve?
>
>
> --
> Stoitcho Goutsev (100)
>
> "Marek" <(E-Mail Removed)> wrote in message
> news:CC464D8A-03CA-45A0-B35F-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      31st Aug 2006
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.


--
Stoitcho Goutsev (100)

"Marek" <(E-Mail Removed)> wrote in message
news:2E95DB79-4D01-438B-A782-(E-Mail Removed)...
> 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
>
> "Stoitcho Goutsev (100)" wrote:
>
>> Marek,
>>
>> What was the question. I kind of missed it. What is that you want to
>> achieve?
>>
>>
>> --
>> Stoitcho Goutsev (100)
>>
>> "Marek" <(E-Mail Removed)> wrote in message
>> news:CC464D8A-03CA-45A0-B35F-(E-Mail Removed)...
>> > 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

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Derived class of StringCOnverter for dynamic propertygrid moni Microsoft C# .NET 1 20th Jul 2007 11:15 PM
Hide a property in derived class in propertygrid =?Utf-8?B?TWF1cmljZU0=?= Microsoft Dot NET 2 20th May 2007 09:31 PM
Instance of derived class does not show public methods or properties that are not in the inherited class D Witherspoon Microsoft Dot NET 5 28th Mar 2006 11:25 PM
Instance of derived class does not show public methods or properties that are not in the inherited class D Witherspoon Microsoft VB .NET 5 28th Mar 2006 11:25 PM
unexpected PropertyGrid behavior on derived WinForm Dave Microsoft Dot NET 0 14th Jul 2005 06:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:33 PM.