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 / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

Custom property on form not persisting value in VS 2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
j.edwards - 11 Jan 2006 01:43 GMT
I posted before about collections but have since tried on a simple single
class and it's not working either. I'm using VB.NET but I thought it now had
the same designtime capabilities as C#.

Here's what I've done...

- New application (CF2)
- New class library in same solution

in the class library...
- make up a new class - just with two simple string properties, e.g.

Public Class Item

   Private _Title As String
   Property Title() As String
       Get
           Return _Title
       End Get
       Set(ByVal value As String)
           _Title = value
       End Set
   End Property

   Private _Value As String
   Property Value() As String
       Get
           Return _Value
       End Get
       Set(ByVal value As String)
           _Value = value
       End Set
   End Property

End Class

- I add a form to the class library and put a property on it of type "Item"
as per above class.

- Then I go into class diagram to add the designer stuff...

- On the form class I've got:
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()
DesignTimeVisible(true)
DesktopCompatible(true)

- On the property of the form I've made up:
TypeConverter(" System.ComponentModel.ExpandableObjectConverter, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ")
Category("_Test")
Description("Test")
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
Browsable(true)

- On the Item class:
DesignTimeVisible(true)
DesktopCompatible(true)

- NOTE: I haven't added any design time stuff to the properties of the Item
class (e.g. "Title", "Value")

In the application I then add a form inheriting from the one in the class
library and in the designer I can see the property, and even change the
values - but when I close the form and re-open it the values are gone. It's
not writing anything to the InitializeComponent() section.

One other question - why can't I see the property in the designer when I
view the "base form" - the one in the class library? why does the "Item"
property only show on inheriting forms?

Any help would be appreciated. Thanks.
j.edwards - 11 Jan 2006 03:30 GMT
I've now tried in both VB and C# - exact same behaviour.
Sam - 11 Jan 2006 07:06 GMT
I also stuck in a 'private bool ShouldSerializeXxx()' method as outlined in
this article for creating custom controls in VS 05:

http://www.symbian.sys-con.com/read/113332_p.htm.

> I've now tried in both VB and C# - exact same behaviour.

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.