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.