下拉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好处就是可以帮你省去编写保证线程互操作安全性的多余代码

提问者评价

谢谢

DiyVM:香港VPS五折月付50元起,2核/2G内存/50G硬盘/2M带宽/CN2线路

diyvm怎么样?diyvm这是一家低调国人VPS主机商,成立于2009年,提供的产品包括VPS主机和独立服务器租用等,数据中心包括香港沙田、美国洛杉矶、日本大阪等,VPS主机基于XEN架构,均为国内直连线路,主机支持异地备份与自定义镜像,可提供内网IP。最近,DiyVM商家对香港机房VPS提供5折优惠码,最低2GB内存起优惠后仅需50元/月。点击进入:diyvm官方网站地址DiyVM香港机房CN...

Linode 18周年庆典活动 不断改进产品结构和体验

今天早上相比很多网友和一样收到来自Linode的庆祝18周年的邮件信息。和往年一样,他们会回顾在过去一年中的成绩,以及在未来准备改进的地方。虽然目前Linode商家没有提供以前JP1优化线路的机房,但是人家一直跟随自己的脚步在走,确实在云服务器市场上有自己的立足之地。我们看看过去一年中Linode的成就:第一、承诺投入 100,000 美元来帮助具有社会意识的非营利组织,促进有价值的革新。第二、发...

火数云-618限时活动,国内云服务器大连3折,限量50台,九江7折 限量30台!

官方网站:点击访问火数云活动官网活动方案:CPU内存硬盘带宽流量架构IP机房价格购买地址4核4G50G 高效云盘20Mbps独享不限openstack1个九江287元/月立即抢购4核8G50G 高效云盘20Mbps独享不限openstack1个九江329元/月立即抢购2核2G50G 高效云盘5Mbps独享不限openstack1个大连15.9元/月立即抢购2核4G50G 高效云盘5Mbps独享不限...

ie地址栏为你推荐
免费开通黄钻怎样能免费开通黄钻会员公章制作在WOLD里怎样制作公章中小企业信息化什么是中小企业信息化途径blogcnblogcn的博客可以搬家到哪些网站?声母是什么哪些是声母,哪些是韵母,微信怎么看聊天记录微信在手机上怎么查看聊天记录去鼠标加速度请问什么是去鼠标加速?去鼠标加速度win7怎么去鼠标加速度怎么在图片上写文字如何在图片上写文字手工杀毒有没有人会手动杀毒.可否详解下
网站空间免备案 虚拟主机试用30天 已备案域名注册 备案未注册域名 万网域名空间 ipage 日本软银 singlehop blackfriday Dedicated 免费主机 一元域名 40g硬盘 200g硬盘 流量计费 789电视剧 吉林铁通 ca187 香港亚马逊 空间登入 更多