如何在组合框中设置建议列表的宽度 [英] How to set the width of the suggest list in a combo box

查看:123
本文介绍了如何在组合框中设置建议列表的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用带有.net4 c#的组合框,我需要动态设置下拉列表的宽度.字符串列表是在运行时从SQL查询添加的.

组合框设置为以下内容:
AutoCompleteMode:SuggestAppend
AutoCompleteSource:ListItems
DropDownStyle:Simple

这会在您键入时提供匹配项列表,但是必须手动调整长字符串的宽度.

我在这里 ^ ],并且在 DropDownStyle:DropDown 时适用于下拉列表,但是如果键入一些文本,则指出的问题仍然很明显.

谁能指出我的解决方案?

Hi
I''m using a combo box with .net4 c# and I need to set the width of the drop down list dynamically. The list of stings are added from a SQL query at run time.

The combo box is set to the following:
AutoCompleteMode:SuggestAppend
AutoCompleteSource:ListItems
DropDownStyle:Simple

This gives a list of matches while you type, but the width has to be manually adjusted for long strings.

I have used the suggested code in here Adjust combo box drop down list width to longest string width[^] and that works for the drop down list when DropDownStyle:DropDown, but if you type in some text, the problem noted is still apparent.

Can anyone point me to a solution?

推荐答案

您是否已在调试器下运行它?

当列表被填充/绑定时,为什么不得到最长的字符串大小(以像素为单位).那时,您不必遍历列表中的项目即可查看最长的项目,并且可以一次设置宽度.
Have you run it under the debugger?

Why don''t you get the longest string size (in pixels) when the list is populated/bound. At that point, you don''t have to cylce through the items in the list to see which one is the longest, and you can set the width one time.


这篇关于如何在组合框中设置建议列表的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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