Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / June 2005

Tip: Looking for answers? Try searching our database.

ExpandableObjectConverter doesn't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CaptainHaddock - 17 Jun 2005 04:15 GMT
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]
> > }
> > }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.