📄 dictionarylister.vb
字号:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Collections
Imports System.Web.UI.WebControls
Namespace WroxControls
Public Class ICollectionLister
Inherits WebControl
Implements INamingContainer
' Step 3
Dim _datasource As ICollection
Public Property DataSource As ICollection
Get
Return _datasource
End Get
Set
_datasource = value
End Set
End Property
Dim _headingStyle As New Style()
Public ReadOnly Property HeadingStyle As Style
Get
Return _headingStyle
End get
End Property
Dim _itemStyle As New Style()
Public ReadOnly Property ItemStyle As Style
Get
Return _itemStyle
End Get
End Property
Protected Overrides Sub CreateChildControls()
Dim e As IEnumerator
Dim l As Label
' Create the heading, using the specified user style
l = New Label()
l.ApplyStyle( _headingStyle )
l.Text = "ICollection Lister Control"
Controls.Add( l )
' Create an label for each key/value pair in the collection
If _datasource Is Nothing Then
Throw New Exception("Control requires a data source")
End If
e = _datasource.GetEnumerator()
While e.MoveNext()
l = new Label()
l.ApplyStyle( _itemStyle )
l.Text = "<BR>" & e.Current.ToString()
Controls.Add( l )
End While
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -