VB.NET类序列化设计器错误
我想自己做菜单。因此,我想为我的菜单体和菜单项使用面板 简而言之,这是我的课堂:VB.NET类序列化设计器错误,vb.net,debugging,serialization,properties,designer,Vb.net,Debugging,Serialization,Properties,Designer,我想自己做菜单。因此,我想为我的菜单体和菜单项使用面板 简而言之,这是我的课堂: Public Class MenuM Inherits System.Windows.Forms.Panel ' Private collectionValue As List(Of MenuMItem) ' Public Property Collection As List(Of MenuMItem) Set(value As List(Of MenuMI
Public Class MenuM
Inherits System.Windows.Forms.Panel
'
Private collectionValue As List(Of MenuMItem)
'
Public Property Collection As List(Of MenuMItem)
Set(value As List(Of MenuMItem))
collectionValue = value
End Set
Get
Return collectionValue
End Get
End Property
'
Public Sub New()
Me.Collection = New List(Of MenuMItem)
End Sub
'
Public Class MenuMItem
Inherits System.Windows.Forms.Panel
End Class
End Class
当我添加Me.Collection=菜单项的新列表时,这是问题所在吗?在构造函数中的第行,我通过设计器和调试器获得序列化错误消息:
尝试将类作为控件添加到主窗体时出现以下错误:
我在尝试开始调试时得到的:
我试图添加上面的公共类菜单项和公共类菜单项。这没用。我不明白这个问题。有人能帮忙吗
非常感谢
这就是解决办法吗?呵呵
资料来源:菜单与普通对照组略有不同。充满子面板的面板不会以相同的方式工作。修复MenuM类的使用。MenuItem是无法修复的,因为在调用onMouseCenter或onMouseWheel之类的事件时,面板中的面板有太多问题,所以我准备将用户控件作为菜单体,其中面板作为菜单项的容器,用户控件作为菜单项。但我仍然有麻烦。这次不是使用滚动等,而是再次使用设计器和调试器。UserControl是一个容器,因此不需要面板。UC也不是菜单,但这是你的意思吗?属性菜单项替换集合属性菜单项为列表菜单项我不知道你在做什么。如果Browsable为false,则不能通过IDE集合编辑器添加任何菜单项,如果没有菜单项,它们如何到达那里?
Imports System
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization
Imports System.Security.Permissions
Imports System.IO
<Serializable()>
Public Class MenuM
Inherits System.Windows.Forms.Panel
Implements ISerializable
'
Public Sub New()
End Sub
'
Protected Sub New(ByVal info As SerializationInfo, _
ByVal context As StreamingContext)
If info Is Nothing Then
Throw New System.ArgumentNullException("info")
End If
collectionValue = info.GetValue("AltMenuMItemList", GetType(List(Of MenuMItem)))
End Sub
'
<SecurityPermission(SecurityAction.LinkDemand, _
Flags:=SecurityPermissionFlag.SerializationFormatter)> _
Public Overridable Sub GetObjectData _
(ByVal info As SerializationInfo, _
ByVal context As StreamingContext) _
Implements ISerializable.GetObjectData
If info Is Nothing Then
Throw New System.ArgumentNullException("info")
End If
info.AddValue("AltMenuMItemList", New List(Of MenuMItem))
End Sub
'
Private collectionValue As List(Of MenuMItem)
'
Public Property Collection As List(Of MenuMItem)
Set(value As List(Of MenuMItem))
collectionValue = value
End Set
Get
Return collectionValue
End Get
End Property
'
<Serializable()>
Public Class MenuMItem
Inherits System.Windows.Forms.Panel
Implements ISerializable
Private textValue As String
Overloads Property Text As String
Set(value As String)
textValue = value
End Set
Get
Return textValue
End Get
End Property
<SecurityPermission(SecurityAction.LinkDemand, _
Flags:=SecurityPermissionFlag.SerializationFormatter)> _
Public Sub GetObjectData(info As System.Runtime.Serialization.SerializationInfo, _
context As System.Runtime.Serialization.StreamingContext) _
Implements System.Runtime.Serialization.ISerializable.GetObjectData
If info Is Nothing Then
Throw New System.ArgumentNullException("info")
End If
textValue = info.GetValue("AltText", GetType(String))
End Sub
Protected Sub New(ByVal info As SerializationInfo, _
ByVal context As StreamingContext)
If info Is Nothing Then
Throw New System.ArgumentNullException("info")
End If
info.AddValue("AltText", "XXX")
End Sub
Sub New()
End Sub
End Class
End Class