调整文本框上的自动完成下拉列表宽度
我正在使用自定义 AutoCompleteSource 设置的 .NET 2 winforms 应用程序中的文本框。 无论如何,我可以通过代码增加包含自动完成建议的列表的宽度吗?
理想情况下,我希望在不增加文本框宽度的情况下执行此操作,因为用户界面中的空间不足。
I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions?
Ideally I would like to do this without increasing the width of the textbox as I am short for space in the UI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,您可以自动调整文本框的大小,使其仅在需要时才变宽,而不是始终与最长的文本一样宽。
示例来自 http://forums.microsoft.com/MSDN/ ShowPost.aspx?PostID=3311429&SiteID=1
结束类
Not that I know of, but you can auto-size the Textbox so that it is only wide when it needs to be, rather than always as wide as the longest text.
Example from http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3311429&SiteID=1
End Class
嗯,确实没有直接的方法。 您可能必须求助于 TextBox 的子类化(在 Windows API 意义上)才能做到这一点,即使如此,仍然需要进行大量猜测。
Hmmm, there's no direct way really. You'd probably have to resort to subclassing (in the Windows API sense) the TextBox to do that, and even then there'd be a lot of guessing to do.
据我所知,TextBox 类包装了 Windows 附带的完整 AutoComplete API。 遗憾的是,这一事实无法“移植”到 .NET 框架的其他部分。
As far as I know the TextBox class wraps the complete AutoComplete API that comes with Windows. Alas, this fact is not "portable" to other parts of the .NET framework.