HighTechTalks DotNet Forums  

ExpandableObjectConverter doesn't work

Dotnet Framework (WinForms DesignTime) microsoft.public.dotnet.framework.windowsforms.designtime


Discuss ExpandableObjectConverter doesn't work in the Dotnet Framework (WinForms DesignTime) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
CaptainHaddock
 
Posts: n/a

Default ExpandableObjectConverter doesn't work - 06-16-2005 , 10:15 PM






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; }
}
}
}



Reply With Quote
  #2  
Old   
Phil Wright
 
Posts: n/a

Default Re: ExpandableObjectConverter doesn't work - 06-17-2005 , 03:09 PM






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

Quote:
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; }
}
}
}





Reply With Quote
  #3  
Old   
CaptainHaddock
 
Posts: n/a

Default Re: ExpandableObjectConverter doesn't work - 06-19-2005 , 06:30 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 (AT) dotnetmagic (DOT) com> дÈëÓʼþ
news:%23Bjvmh3cFHA.3328 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Quote:
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; }
}
}
}







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.