既能输入又能选择的DropDownList控件
来源:互联网 发布:淘宝消费总额查询 编辑:程序博客网 时间:2024/05/10 16:53
早就想做一个这样的控件了,最近在一个项目中遇到了这样的问题,所以就写了一个。
我遇到的需求是既能输入又能选择的DropDownList,其中输入的是课程成绩,选择的是补考、缓考、缺考。
此控件支持取值和赋值。支持IE6、IE7,其他的没测。
SelectTextBox.ascx
<style type="text/css">
.cls{
POSITION:absolute;
}
</style>
<div class="cls" style="WIDTH: 85px;z-index:100" align="center">
<iframe style="position:absolute;z-index:-1;width:expression(this.nextSibling.offsetWidth);height:expression(this.nextSibling.offsetHeight);top:expression(this.nextSibling.offsetTop);left:expression(this.nextSibling.offsetLeft);" frameborder="0" ></iframe>
<asp:TextBox ID="TextBox1" runat="server" Width="85px" Height="15px" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
</div>
<asp:DropDownList ID="DropDownList1" runat ="server" Width="107px" Height="20px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True" ></asp:DropDownList>
SelectTextBox.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace JKCollegeManage.WebPage.Score
{
public partial class SelectTextBox : System.Web.UI.UserControl
{
private string _text;
protected void Page_Load(object sender, EventArgs e)
{
}
// Text 重写了TextBox的Text属性
public String Text
{
get
{
_text = this.TextBox1.Text;
return _text;
}
set
{
this.TextBox1.Text = value;
_text = this.TextBox1.Text;
}
}
//为控件增加一个可选择的项
public void AddItem(String item)
{
this.DropDownList1.Items.Add(item);
}
//为控件增加一个可选择的项
public void AddItem(ListItem item)
{
this.DropDownList1.Items.Add(item);
}
//为控件增删除一个可选择的项
public void RemoveItem(ListItem item)
{
this.DropDownList1.Items.Remove(item);
}
//为控件增删除一个可选择的项
public void RemoveItem(String item)
{
this.DropDownList1.Items.Remove(item);
}
//清除控件数据
public void Clear()
{
this.DropDownList1.Items.Clear();
this.TextBox1.Text = "";
}
//返回选项数量
public int Count
{
get
{
return this.DropDownList1.Items.Count;
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
//选择某项
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.TextBox1.Text = this.DropDownList1.SelectedItem.Text;
}
}
}
- 既能输入又能选择的DropDownList控件
- DropDownList既能选择又能输入
- DropDownList既能选择又能输入
- DropDownList既能选择又能输入
- DropDownList既能选择又能输入
- DropDownList既能选择又能输入
- 既能输入又能选择的DropDownList
- DropdownList既能输入也能选择
- 既能输入又能选择的下拉框
- ASP.NET中如何让DropDownList控件既能做选择又能做输入用?
- 又能选择又能输入
- 让下拉列表又能选择又能输入
- 既能实现下拉又能实现输入的文本框
- 标题:如何在dropDownList中实现既能输入一个新值,又能实现下拉选
- 一个既可以下拉选择,又可以输入的DropDownList
- 选择输入控件,既可以输入又可以选择的控件
- 一个能识别@xxxx 标志从而整块选择与删除的输入框控件。
- 如何用C#做一个即能显示文字又能显示图片的控件
- 使用Microsoft HTML Help Workshop制作CHM帮助文件
- 汉字笔画的计算。
- Windows Mobile 6 (1) ----Windows Mobile 6 中为开发人员提供的新功能
- 按比例保存图片
- 上传图片到数据库及显示
- 既能输入又能选择的DropDownList控件
- 某大型电子商务网站在招一个PHP开发经理
- 工程传奇——会飞的猪
- Linux系统下C语言编程 线程操作入门常识
- An Introduction to Project Management
- informatica 面试题大全(持续更新)
- 删除多级非空目录
- 扫雷秘籍
- 软件开发注定失败的26个信号