textbox 有一个AutoCompleteSource 设置后输入相关匹配字符后会自动显示一个下拉列表选择
这个自动显示的下拉列表如何自定义控制他的显示呢
如何当textbox接受焦点的时候就显示? 如何输入拼音搜索相关数据后显示
就类似于极品火车时刻表那样的
谢谢
这个自动显示的下拉列表如何自定义控制他的显示呢
如何当textbox接受焦点的时候就显示? 如何输入拼音搜索相关数据后显示
就类似于极品火车时刻表那样的
谢谢
解决方案 »
- 数组排序问题!!
- 求书---WPF编程宝典:使用C# 2008和.NET 3.5(第2版)
- 关于using()语句,()中的问题
- 项目中的类按类名生成多个dll
- asp.net2008(C#)如何设置团队开发?
- C# Winform listBox 怎样点右键选中一行数据..................帮下忙哟!!!!!!!!!!!!!
- 请问数据结构到底是做什么用的?
- List.Sort(Comparison) 的实现原理是怎样的,为何比我自己写的排序算法效率高很多?
- Array的显式接口实现?
- C#正试版什么时候出来???
- 这怎么解决啊?
- System.Net.Mail发邮件,jmail收邮件
此时根据文本内容进行模糊查询
将查询的结果显示出来
~
或者添加一个隐藏的listview,根据text的内容显示和隐藏。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body{background:#fff}
.Menu {
position:relative;
width:204px;
height:127px;
z-index:1;
background: #FFF;
border:1px solid #000;
margin-top:-100px;
display:none;
}
.Menu2 {
position: absolute;
left:0;
top:0;
width:100%;
height:auto;
overflow:hidden;
z-index:1;
}
.Menu2 ul{margin:0;padding:0}
.Menu2 ul li{width:100%;height:25px;line-height:25px;text-indent:15px;
border-bottom:1px dashed #ccc;color:#666;cursor:pointer;
change:expression(
this.onmouseover=function(){
this.style.background="#F2F5EF";
},
this.onmouseout=function(){
this.style.background="";
}
)
}
input{width:200px}
.form{width:200px;height:auto;}
.form div{position:relative;top:0;left:0;margin-bottom:5px}
#List1,#List2,#List3{left:0px;top:93px;}
-->
</style>
<script type="text/javascript">
function showAndHide(obj,types){
var Layer=window.document.getElementById(obj);
switch(types){
case "show":
Layer.style.display="block";
break;
case "hide":
Layer.style.display="none";
}
}
function getValue(obj,str){
var input=window.document.getElementById(obj);
input.value=str;
}
</script>
</head>
<body>
<div class="form">
<div> Location:<input type="text" id="txt" name="txt" onClick="showAndHide('List1','show');" onblur="showAndHide('List1','hide');"></div>
<!--列表1-->
<div class="Menu" id="List1">
<div class="Menu2">
<ul>
<li onmousedown="getValue('txt','中国CHINA');showAndHide('List1','hide');">中国CHINA</li>
<li onmousedown="getValue('txt','美国USA');showAndHide('List1','hide');">美国USA</li>
</ul>
</div>
</div><div> Sex:<input type="text" id="txt2" name="txt2" onClick="showAndHide('List2','show');" onblur="showAndHide('List2','hide');"></div>
<!--列表2-->
<div class="Menu" id="List2">
<div class="Menu2">
<ul>
<li onmousedown="getValue('txt2','男Male');showAndHide('List2','hide');">男Male</li>
<li onmousedown="getValue('txt2','女Female');showAndHide('List2','hide');">女Female</li>
</ul>
</div>
</div>
<div> education:<input type="text" id="txt3" name="txt3" onClick="showAndHide('List3','show');" onblur="showAndHide('List3','hide');"></div>
<!--列表3-->
<div class="Menu" id="List3">
<div class="Menu2">
<ul>
<li onmousedown="getValue('txt3','大专');showAndHide('List3','hide');">大专</li>
<li onmousedown="getValue('txt3','本科');showAndHide('List3','hide');">本科</li>
<li onmousedown="getValue('txt3','硕士');showAndHide('List3','hide');">硕士</li>
<li onmousedown="getValue('txt3','本科');showAndHide('List3','hide');">本科</li>
</ul>
</div>
</div>
</div>
</body>
</html>
==================================
combox控件可以改造成textbox外观,
只需设置:comboBox1.DropDownStyle = ComboBoxStyle.Simple;
要自动完成文字联想,设置:
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
要搜索时候查询数据库,添加TextChanged事件,在事件中查询并重新绑定数据源:
comboBox1.DataSource=new string[] {"", "ssss", "123", "shdchsg" };