![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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; } } } } |
#3
| |||
| |||
|
|
Try adding the following attribute to your 'public Person Manager' property definition. [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)] Phil Wright Follow my microISV startup for c# components at... http://componentfactory.blogspot.com "CaptainHaddock" <chenrong2003 (AT) gmail (DOT) com> wrote in message news:uJGzhqucFHA.892 (AT) tk2msftngp13 (DOT) phx.gbl... 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; } } } } |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |