⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comboboxdesigner.cs

📁 ASP中web自定义控件的使用源码及说明文档
💻 CS
字号:
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;

namespace Bestcomy.Web.UI.WebControls
{
	/// <summary>
	/// 
	/// </summary>
	public class ComboBoxDesigner : ControlDesigner
	{
		private ComboBox comboBox;

		public ComboBoxDesigner()
		{
		}

		public override void Initialize(System.ComponentModel.IComponent component)
		{
			base.Initialize (component);
			this.comboBox = (ComboBox)component;
		}


		public override string GetDesignTimeHtml()
		{
			DropDownList drop = new  DropDownList();
			if(this.comboBox.Items.Count > 0)
			{
				foreach(ComboItem item in comboBox.Items)
				{
					ListItem litem = new ListItem(item.Text,item.Text);
					if(item.Selected)
						litem.Selected = true;
					drop.Items.Add(litem);
				}
			}
			else
			{
				drop.Items.Add(new ListItem("Unbound"));
			}
			drop.Width = comboBox.Width;
			StringWriter sw = new StringWriter();
			HtmlTextWriter tw = new HtmlTextWriter(sw);
			drop.RenderControl(tw);
			return sw.ToString();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -