当前位置:IT168首页 > 技术开发 > 概述
[收藏此页] [打印] [推荐] [评论]

扩展DropDownList控件和ListBox控件 - 支持分组功能(optgroup标签)

责任编辑:nancy作者:ITPUB论坛   2008-05-14   
【内容导航】
文本Tag: 微软 sql

【IT168技术文档】

  扩展DropDownList控件和ListBox控件:
  通过DropDownList控件和ListBox控件的.Items.Add(ListItem item)方法,来为其添加optgroup标签,从而实现分组功能


  使用方法
  1、设置属性:
  OptionGroupValue - 用于添加DropDownList(ListBox)控件的分组项的ListItem的Value值(默认为optgroup)
  2、使用DropDownList(ListBox)控件的.Items.Add(ListItem item)方法:
  OptionGroupValue为默认值时:SmartDropDownList.Items.Add(new ListItem("中国", "optgroup"));

  关键代码(以DropDownList为例)
  SmartDropDownList.cs
using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using System.Web.UI; [assembly: System.Web.UI.WebResource("YYControls.SmartDropDownList.Resources.Icon.bmp", "image/bmp")] namespace YYControls { /**//// <summary> /// SmartDropDownList类,继承自DropDownList /// </summary> [ToolboxData(@"<{0}:SmartDropDownList runat='server'></{0}:SmartDropDownList>")] [System.Drawing.ToolboxBitmap(typeof(YYControls.Resources.Icon), "SmartDropDownList.bmp")] public partial class SmartDropDownList : DropDownList { /**//// <summary> /// 构造函数 /// </summary> public SmartDropDownList() { } /**//// <summary> /// 将控件的内容呈现到指定的编写器中 /// </summary> /// <param name="writer">writer</param> protected override void RenderContents(HtmlTextWriter writer) { // 呈现Option或OptionGroup OptionGroupRenderContents(writer); } } }
上一页
1
2下一页
收藏到: 添加到“百度搜藏”添加到“QQ书签”添加到“Google书签”添加到“Yahoo收藏”添加到“和讯网摘”
【内容导航】
本文欢迎转载,转载请注明:转载自IT168 [ http://www.it168.com/ ]
本文链接:http://tech.it168.com/d/2008-05-14/200805142143296.shtml
技术开发相关文章   .net server SQL 微软
  • 暂无
友情推介