Custom property on form not persisting value in VS 2005

J

j.edwards

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top