📄 dictionarylister.cs
字号:
using System;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Web.UI.WebControls;
namespace WroxControls
{
public class ICollectionLister : WebControl, INamingContainer
// Step 3
{
ICollection _datasource;
public ICollection DataSource
{
get { return _datasource; }
set { _datasource = value; }
}
Style _headingStyle = new Style();
public Style HeadingStyle
{
get{ return _headingStyle; }
}
Style _itemStyle = new Style();
public Style ItemStyle
{
get{ return _itemStyle; }
}
protected override void CreateChildControls()
{
IEnumerator e;
Label l;
// 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 == null )
throw new Exception("Control requires a data source");
e = _datasource.GetEnumerator();
while( e.MoveNext() )
{
l = new Label();
l.ApplyStyle( _itemStyle );
l.Text = "<BR>" + e.Current.ToString();
Controls.Add( l );
}
}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -