all groups > dotnet windows forms designtime > june 2005 >
You're in the

dotnet windows forms designtime

group:

ExpandableObjectConverter doesn't work


ExpandableObjectConverter doesn't work CaptainHaddock
6/17/2005 12:00:00 AM
dotnet windows forms designtime:
Hi, everyone,

I'm a newbie to the winform designtime area, Now I'm learning the usage of
PropertyGrid. when I added one custom type of property "Person" to the class
"Company", it didn't appear in the PropertyGrid. I had used the
ExpandableObjectConverter as the TypeConverter of the property.
(My envirement is .NET framework 1.1)

Can anyone help me? thank you very much.

Regards, Haddock

----------------------
and here is the code:
----------------------

using System;
using System.Windows.Forms;
using System.ComponentModel;

namespace PropertyGridTest1
{
public class Test : System.Windows.Forms.Form {
public static void Main() {
Application.Run(new Test());
}

public Test() {
PropertyGrid pg = new PropertyGrid();
this.Controls.Add(pg);
pg.Dock = DockStyle.Fill;
pg.SelectedObject = new Company();
}
}

public class Company
{
Person manager = new Person();

Person Manager {
get { return manager; }
set { manager = value; }
}

string name = "";

public string Name {
get { return name; }
set { name = value; }
}
}

[TypeConverter(typeof(ExpandableObjectConverter))]
public class Person
{
string firstname = "";
string lastname = "";

public string FirstName {
get { return firstname; }
set { firstname = value; }
}

public string LastName {
get { return lastname; }
set { lastname = value; }
}
}
}

Re: ExpandableObjectConverter doesn't work Phil Wright
6/17/2005 9:09:03 PM
Try adding the following attribute to your 'public Person Manager' property
definition.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

Phil Wright
Follow my microISV startup for c# components at...
http://componentfactory.blogspot.com


[quoted text, click to view]

Re: ExpandableObjectConverter doesn't work CaptainHaddock
6/19/2005 12:00:00 AM
I have found that it's a silly mistake.
I forgot to put a 'public' before the 'Person Manager' property.

Thanks for your advice.

Regards, Haddock

"Phil Wright" <phil.wright@dotnetmagic.com> дÈëÓʼþ
news:%23Bjvmh3cFHA.3328@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button