我如何为可编辑的文本框自动完成列表? [英] How do I make the autocomplete list for a TextBox editable?

查看:150
本文介绍了我如何为可编辑的文本框自动完成列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多文本框使用自动完成控件的应用程序。每一个使用 AutoCompleteMode.CustomSource 来获得相关的 AutoCompleteStringCollection

I have an application with a lot of TextBox controls that use autocomplete. Each one uses AutoCompleteMode.CustomSource to get the autocomplete text from an associated AutoCompleteStringCollection.

当用户输入在文本框一个新的价值,它被添加到相关 AutoCompleteStringCollection ,并在所有这些藏品得到保存到用户的主目录的文件在会议结束。

Whenever the user enters a new value in the TextBox, it gets added to the associated AutoCompleteStringCollection, and at the end of the session all of those collections get persisted to a file in the user's home directory.

的问题是,有没有办法来纠正错误这些集合。在IE浏览器,输入控制与自动完成控制让你滚动到自动完成列表,然后按删除将其删除的项目。这并不在.NET控件工作。

The problem is that there's no way to correct errors in those collections. In IE, input controls with autocomplete controls let you scroll to an item in the autocomplete list and press Del to remove it. That doesn't work in the .NET controls.

我真的很想以避免实施这个我自己的UI。我是坚持?有没有一种方法,使这一点,我没有看到?

I'd really like to avoid having to implement my own UI for this. Am I stuck? Is there a way to enable this that I'm not seeing?

推荐答案

开箱即用,无有什么可以做这为你可惜。我试图P /调用基本FindWindowEx / EnumChildWindows,看看我是否能得到一个处理实际下拉,但是不成功的(如果有人确实设法把这事办成,让我知道!)。好消息是(不那么好,但并不可怕)是自动完成的其实不是你完全有实现自己的东西,居然有所谓的 SHAutoComplete ,可以P /调用,以帮助您自动完成。不要高兴得太早,但因为它不是只是P /调用它简单而用它来完成。然而,有一个伟大的 CodeProject上的文章应该帮助你极大。

Out of the box, no there's nothing to do this for you unfortunately. I tried P/Invoking the basic FindWindowEx / EnumChildWindows to see if I can get a Handle to the actual drop down, but was unsuccessful (if someone does manage to pull this off, let me know!). The good news is (not so good, but not terrible) that the auto complete isn't actually something you completely have to implement yourself, there's actually a Win32 function called SHAutoComplete that can be P/Invoked to help you with the auto completion. Don't get too excited yet, because it's not as simple as just P/Invoking it and be done with it. However, there's a great CodeProject article that should help you out tremendously.

这篇关于我如何为可编辑的文本框自动完成列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆