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; }
}
}
}
Phil Wright - 17 Jun 2005 21:09 GMT
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
> Hi, everyone,
>
[quoted text clipped - 66 lines]
> }
> }
CaptainHaddock - 19 Jun 2005 12:30 GMT
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
> Try adding the following attribute to your 'public Person Manager' property
> definition.
[quoted text clipped - 74 lines]
> > }
> > }