下拉combobox输入自动提示(仿ie地址栏)c (ComboBox input automatically prompts (imitation IE address bar) c )

ie地址栏  时间:2021-02-27  阅读:()

combobox输入自动提示(仿ie地址栏)c# ComboBox inputautomatically prompts (imitation IE address bar) c#Recently, when you do projects, you need to use comboBox toimplement the functions similar to IE drop-down lists! The mostdirect way is to monitor the comboBox textChanged event, whenthe event occurs, the data from (I use arrayList to store datatemporarily) with string matching, and then added to thedrop-down list in the comboBox.

1 : how to display drop-down list in textChanged, because thedisplay drop-down list is usually the user click the drop-downarrow displayed, and later use comboBox1.DroppedDown = true;can display the contents of the drop-down list.

2: add content to the drop-down list: comboBox1. Items.Add (STR) ;use this statement to add STR to the drop-down list

3: delete the contents of the drop-down list?When comboBox textis changed, the original, down the contents of the list may nolongermatch, somy idea is to change every time text will deleteall contents drop-down list, and then re iterates over thecollection, will match the contents of re added to the drop-downlist: (comboBox1. Items.Clear) ; but this statement will be a theproblem is text, the cursor will automatically go to the left:so, this line did not continue, but found that the mouse willrealize sometimes lost the cursor, don' t feel very well!

4: later found that comboBox and textBox support built-insearch prompt function, add the following statement in form' sInitial izeComponent () :

This.comboBox1.AutoCompleteCustomSource.AddRange (Newstring[] {"10. 152. 154.89", "10. 152. 154.90", "10. 152.252. 10","10. 152.252. 11"} ) ;

This.comboBox1.AutoCompleteMode =

System.Windows.Forms.AutoCompleteMode.Suggest;

This.comboBox1.AutoCompleteSource =

System.Windows.Forms.AutoCompleteSource.CustomSource;Where this.comboBox1.AutoCompleteCustomSource.AddRange (Newstring[] {"10. 152. 154.89", "10. 152. 154.90", "10. 152.252. 10","10. 152.252. 11"} ) is the addition of data to the search rangeThis.comboBox1.AutoCompleteMode =

System.Windows.Forms.AutoCompleteMode.Suggest;

Set comboBox to complete the built-in search, the default isNone, and Append, and SuggestAppend attributes, in addition tothe default None can achieve search tips function, but theappearance is different

This.comboBox1.AutoCompleteSource =

System.Windows.Forms.AutoCompleteSource.CustomSource; makethe search range, this is because I use new string[]

{"10. 152. 154.89", "10. 152. 154.90", "10. 152.252. 10",

"10. 152.252. 11"} as the search scope, so defined as

Cust omS our ce

System.Windows.Forms.AutoCompleteSource also has a Allurl

property, if you change the code to

This.comboBox1.AutoCompleteMode =

System.Windows.Forms.AutoCompleteMode.Suggest;this.comboBox1.AutoCompleteSource =

System.Windows.Forms.AutoCompleteSource.Al lurl;

In this way, the comboBox can achieve the same function as theIE drop-down list, other attributes such as AllSystemSourcescan try to own, so that the completion of the comboBox searchprompt function.

Can you share the code?. Thanks。 My EMAIL:panjun11@163.com#2 floor 2009-12-11 15:54 Longkin

This.comboBox1.AutoCompleteSource =

System.Windows.Forms.AutoCompleteSource.Al lurl;

If comboBox1 has a data source, you can use

AutoCompleteSource.ListItems directly;

Support (0) against (0)

# 3楼2009-12-11 longkin 15:56

还有建议用这个autocompletemode. suggestappend

效果稍微好点

支持0 0反对

# 4楼2010-01-26 17:09张磊张拉里。

能否像dropdownwi dth一样修改提示框的宽度

我找不到类似属性

支持0 0反对

# 5楼2012-01-31 14:17 mo_mo_mo

@ Longkin

正解把你的两条意见实施了效果不错

感谢楼主感谢longki n

C#中ComboBox下拉选中一个后下面的TextBox自动显示数据库里对应的值

2014-03-01 18: 14域雪无痕|分类 C # / .NE T |浏览206次如访问中一表有姓名电话地址。在ComboBox中选中某一姓名对应的TextBox显示其号码用SelectedIndexChanged监听代码分享到

2014-03-01 18:25提问者采纳答题闯关过关即送礼快来参加~Web还是赢

赢得的话监听SelectedIndexChanged

Web的话最好还是用JavaScript在客户端实现

追问

知道用SelectedIndexChanged代码如何写

回答

那就是说是赢得咯

首先得看你ComboBox是那种类型的根据不同的类型会有以下几种方式能获取到当前选中的下拉菜单你分别试试

组合框。 tostring() SelectedValue

组合框。 tostring()教科书选文

如果是直接DataSource等于表的话要先拆箱出来

模型组合。 SelectedItem。姓名

得到姓名之后写textbox.text =姓名就行了

提问者评价

谢谢

3条回答其他

2014-03-01 18: 19 xmandlp |七级

在ComboBox的selectindexchanged事件中添加你查询数据库的代码把查询结果赋值到TextBox就可以了

追问

知道这么做代码不会写啊数据库是访问的 ComboBox的值与对相对应

评论| 0 0

2014-03-01 18:23 ckvming |四级

你在页面加载的时候首先要绑定好ComboBox的数据源。

然后下拉的时候就会自动显示选定的值了。

C #中ComboBox或者教材怎么实现记忆联想功能求指导  2013-09-04 00:48f sf snake |分类 C # / .NET |浏览178次C#在形式窗体中用Comb oBox或教材怎么实现记忆联想功能就是当输入任何字符是都会弹出一个下拉菜单提示含有该字符的字符串教材的就是提示之前曾经输入过的字符串而ComboBox的就是提示编辑项里面事先输入的字符串这两个控件的autocomp let esource的属性已设为设置 autocompletemode属性为suggestappend但还是没有一点效果希望能详细点谢谢求大神指导

分享到

2013-09-04 13:45提问者采纳答题闯关过关即送礼快来参加~在控件录入或ontextchange事件加入监听函数捕获输入内容显示相应推送结果

追问

新手希望大侠指导下谢谢可以相信说明下吗

回答

专门做个检索线程不用直接用BackgroundWorker好处就是可以帮你省去编写保证线程互操作安全性的多余代码

提问者评价

谢谢

轻云互联22元/月,美国硅谷、圣何塞CN2GIA云服务器,香港沙田cn2建站vps仅25元/月

轻云互联怎么样?轻云互联,广州轻云网络科技有限公司旗下品牌,2018年5月成立以来,轻云互联以性价比的价格一直为提供个人,中大小型企业/团队云上解决方案。本次轻云互联送上的是美国圣何塞cn2 vps(免费50G集群防御)及香港沙田cn2 vps(免费10G集群防御)促销活动,促销产品均为cn2直连中国大陆线路、采用kvm虚拟技术架构及静态内存。目前,轻云互联推出美国硅谷、圣何塞CN2GIA云服务器...

快快云:香港沙田CN2/美国Cera大宽带/日本CN2,三网直连CN2 GIA云服务器和独立服务器

快快云怎么样?快快云是一家成立于2021年的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,快快云目前提供有香港云服务器、美国云服务器、日本云服务器、香港独立服务器、美国独立服务器,日本独立服务器。快快云专注为个人开发者用户,中小型,大型企业用户提供一站式核心网络云端服务部署,促使用户云端部署化简为零,轻松快捷运用云计算!多年云计算领域服务经验,遍布亚太地区的海量节点为业务推进提供强大...

Ceraus24元/月,国庆促销 香港云上新首月五折

Ceraus数据成立于2020年底,基于KVM虚拟架构技术;主营提供香港CN2、美国洛杉矶CN2、日本CN2的相关VPS云主机业务。喜迎国庆香港上新首月五折不限新老用户,cera机房,线路好,机器稳,适合做站五折优惠码:gqceraus 续费七五折官方网站:https://www.ceraus.com香港云内存​CPU硬盘流量宽带优惠价格购买地址香港云2G2核40G不限5Mbps24元/月点击购买...

ie地址栏为你推荐
怎么点亮qq空间图标QQ空间图标怎么点亮?ios系统ios系统的手机有哪些?发邮件怎么发发邮件怎么发?微信电话本怎么用微信电话本如何使用?去鼠标加速度请教如何正确的去处鼠标加速度~关闭qq相册图标如何关闭QQ相册图标之后保留空间相片关闭qq相册图标怎样熄灭QQ相册图标关闭qq相册图标如何关闭QQ相册的图标12580拨打12580有什么作用?外网访问内网怎么实现外网访问内网路由器
www二级域名 高防服务器租用qy 域名查询系统 域名服务器是什么 国内免备案主机 godaddy续费优惠码 英语简历模板word iis安装教程 最好看的qq空间 html空间 hostker 新家坡 中国电信测速网 如何用qq邮箱发邮件 空间技术网 服务器硬件防火墙 卡巴斯基是免费的吗 美国凤凰城 web应用服务器 西安主机 更多