Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 用户控件列表属性设计器错误_Vb.net_List_Controls_Properties - Fatal编程技术网

Vb.net 用户控件列表属性设计器错误

Vb.net 用户控件列表属性设计器错误,vb.net,list,controls,properties,Vb.net,List,Controls,Properties,我想向我的用户控件添加一个列表(书籍)属性。我为CollectionEditor定义了Book类和BookCollectionEditor类。我还为我的用户控件定义了一个名为BookList的公共属性。对于自定义控件,它可以正常工作,但对于用户控件,设计器不显示“我的属性”。在标记上,我可以添加书籍项,但在设计器上,它会出现错误:“Type'System.Web.UI.UserControl'没有名为'BookList'的公共属性。” 不能为用户控件定义列表属性吗 <TypeConvert

我想向我的用户控件添加一个列表(书籍)属性。我为CollectionEditor定义了Book类和BookCollectionEditor类。我还为我的用户控件定义了一个名为BookList的公共属性。对于自定义控件,它可以正常工作,但对于用户控件,设计器不显示“我的属性”。在标记上,我可以添加书籍项,但在设计器上,它会出现错误:“Type'System.Web.UI.UserControl'没有名为'BookList'的公共属性。”

不能为用户控件定义列表属性吗

<TypeConverter(GetType(ExpandableObjectConverter)), Serializable()> _
Public Class Book
  Private _name As String
  Private _author As String

  Public Sub New()
    Me.New(String.Empty, String.Empty)
  End Sub

  Public Sub New(ByVal name As String, ByVal author As String)
    _name = name
    _author = author
  End Sub

  <Category("Book Property"), Description("Name of the Book"), DefaultValue(""), NotifyParentProperty(True)> _
  Public Property Name() As String
    Get
      Return _name
    End Get
    Set(ByVal value As String)
      _name = value
    End Set
  End Property

  <Category("Book Property"), Description("Author of the Book"), DefaultValue(""), NotifyParentProperty(True)> _
  Public Property Author() As String
    Get
      Return _author
    End Get
    Set(ByVal value As String)
      _author = value
    End Set
  End Property
End Class

Public Class BookCollectionEditor
  Inherits CollectionEditor

  Public Sub New(ByVal newType As Type)
    MyBase.new(newType)
  End Sub

  Protected Overrides Function CanSelectMultipleInstances() As Boolean
    Return False
  End Function

  Protected Overrides Function CreateCollectionItemType() As Type
    Return GetType(Book)
  End Function
End Class

Partial Class BooksUserControl
  Inherits System.Web.UI.UserControl

  Private _booklist As New List(Of Book)

  <Category("Behavior"), _
   Description("Book List"), _
   DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
   NotifyParentProperty(True), _
   PersistenceMode(PersistenceMode.InnerProperty), _
   Editor(GetType(BookCollectionEditor), GetType(BookCollectionEditor)), _
   Browsable(True)> _
  Public ReadOnly Property BookList() As List(Of Book)
    Get
      If _booklist Is Nothing Then
        _booklist = New List(Of Book)()
      End If
      Return _booklist
    End Get
  End Property
End Class
_
公共课堂用书
Private\u名称作为字符串
Private\u author作为字符串
公共分新()
Me.New(String.Empty,String.Empty)
端接头
Public Sub New(ByVal name作为字符串,ByVal author作为字符串)
_name=name
_作者
端接头
_
作为字符串的公共属性名()
收到
返回\u名称
结束
设置(ByVal值作为字符串)
_名称=值
端集
端属性
_
公共属性Author()作为字符串
收到
返回作者
结束
设置(ByVal值作为字符串)
_作者=价值
端集
端属性
末级
公共类BookCollectionEditor
继承集合编辑器
Public Sub New(ByVal newType作为类型)
MyBase.new(新类型)
端接头
受保护的覆盖函数可以选择MultipleInstances()作为布尔值
返回错误
端函数
受保护的重写函数CreateCollectionItemType()作为类型
返回GetType(Book)
端函数
末级
部分类用户控制
继承System.Web.UI.UserControl
私人书单作为新书单(书籍)
_
公共只读属性BookList()作为(书本的)列表
收到
如果你的书单什么都不是
_booklist=新列表(书籍)()
如果结束
还书单
结束
端属性
末级
Default.aspx

<uc1:BooksUserControl ID="BooksUserControl1" runat="server">
  <BookList>
  </BookList>
</uc1:BooksUserControl>


是可以定义(T)属性列表。请在不使用编辑器设置的情况下尝试代码,以查看问题是否存在于代码的该部分。

是可以定义(T的)列表属性。在没有编辑器设置的情况下尝试代码,看看问题是否出在代码的该部分。

但是,如果没有编辑器设置,如何从属性窗口添加项目?如果没有编辑器设置,如何从属性窗口添加项目?