Consider the following example code:
...
namespace MyNamespace
{
public class MyClass
{
private int m_Count;

[TypeConverter(typeof(ExpandableObjectConverter))]
public int Count
{
get { return m_Count; }
set { m_Count= value; }
}

// ....etc...
}
}

When setting a PropertyGrid's SelectedObject to an instance of this class,
it shows "MyNamespace.MyClass"...can I change that so that it displays
something more user friendly? It just looks tacky and I'd like to fix it :)

Any tips would be appreciated!

TIA
-sb

Re: Property Grid question (simple?) by Jon

Jon
Mon Jun 12 20:42:28 CDT 2006

sb wrote:

> namespace MyNamespace
> {
> public class MyClass

> When setting a PropertyGrid's SelectedObject to an instance of this class,
> it shows "MyNamespace.MyClass"...can I change that so that it displays
> something more user friendly? It just looks tacky and I'd like to fix it :)

The short answer is Yes.

> Any tips would be appreciated!

The long(er) answer is that this is sort of complicated, and that
there are samples online. Try Googling - you'll find plenty.

--

.NET 2.0 for Delphi Programmers <http://www.midnightbeach.com/.net>

Delphi skills make .NET easy to learn
Just printed, and shipping now.

Re: Property Grid question (simple?) by sb

sb
Tue Jun 13 16:59:25 CDT 2006

I did try googling...but I used the wrong terms. Anyway, I figured it out:
public sealed class MyExpandableObjectConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value, Type
destinationType)
{
return "MyName";
}
}

Not that tough after all.

Thanks.
-sb



"Jon Shemitz" <jon@midnightbeach.com> wrote in message
news:448E1804.AA6B9653@midnightbeach.com...
> sb wrote:
>
>> namespace MyNamespace
>> {
>> public class MyClass
>
>> When setting a PropertyGrid's SelectedObject to an instance of this
>> class,
>> it shows "MyNamespace.MyClass"...can I change that so that it displays
>> something more user friendly? It just looks tacky and I'd like to fix it
>> :)
>
> The short answer is Yes.
>
>> Any tips would be appreciated!
>
> The long(er) answer is that this is sort of complicated, and that
> there are samples online. Try Googling - you'll find plenty.
>
> --
>
> .NET 2.0 for Delphi Programmers <http://www.midnightbeach.com/.net>
>
> Delphi skills make .NET easy to learn
> Just printed, and shipping now.



Re: Property Grid question (simple?) by JJ

JJ
Tue Jun 13 22:59:56 CDT 2006

By default, PropertyGrid calls ToString() to display this value.

You can simply override the ToString() function in MyClass to return your
friendly value.

Good Luck
Jeff http://www.ruamkwamkid.com

"sb" <stormfire1@yahoo.com> wrote in message
news:ejusTQojGHA.4344@TK2MSFTNGP05.phx.gbl...
> Consider the following example code:
> ...
> namespace MyNamespace
> {
> public class MyClass
> {
> private int m_Count;
>
> [TypeConverter(typeof(ExpandableObjectConverter))]
> public int Count
> {
> get { return m_Count; }
> set { m_Count= value; }
> }
>
> // ....etc...
> }
> }
>
> When setting a PropertyGrid's SelectedObject to an instance of this class,
> it shows "MyNamespace.MyClass"...can I change that so that it displays
> something more user friendly? It just looks tacky and I'd like to fix it
> :)
>
> Any tips would be appreciated!
>
> TIA
> -sb
>



Re: Property Grid question (simple?) by sb

sb
Thu Jun 15 18:01:46 CDT 2006

Thanks! That's even simpler...now I feel dumb since I shoulda known that :)

-sb

"JJ" <chingwaah@hotmail.com> wrote in message
news:eZB2Cc2jGHA.3496@TK2MSFTNGP02.phx.gbl...
> By default, PropertyGrid calls ToString() to display this value.
>
> You can simply override the ToString() function in MyClass to return your
> friendly value.
>
> Good Luck
> Jeff http://www.ruamkwamkid.com
>
> "sb" <stormfire1@yahoo.com> wrote in message
> news:ejusTQojGHA.4344@TK2MSFTNGP05.phx.gbl...
>> Consider the following example code:
>> ...
>> namespace MyNamespace
>> {
>> public class MyClass
>> {
>> private int m_Count;
>>
>> [TypeConverter(typeof(ExpandableObjectConverter))]
>> public int Count
>> {
>> get { return m_Count; }
>> set { m_Count= value; }
>> }
>>
>> // ....etc...
>> }
>> }
>>
>> When setting a PropertyGrid's SelectedObject to an instance of this
>> class, it shows "MyNamespace.MyClass"...can I change that so that it
>> displays something more user friendly? It just looks tacky and I'd like
>> to fix it :)
>>
>> Any tips would be appreciated!
>>
>> TIA
>> -sb
>>
>
>