在组合框中显示几个项目:::: VB.Net [英] Displaying few items in combo box :::: VB.Net

查看:76
本文介绍了在组合框中显示几个项目:::: VB.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的组合框中有近50项。我想将它们全部加载到组合中但只想显示少量(最多10个)项目。

可以设置,以便当用户单击组合时,显示的项目很少,再次单击时,全部显示?



谢谢

解决方案

要控制组合框中显示的项目数量,你可以使用 MaxDropDownItems [< a href =https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.maxdropdownitems(v=vs.110).aspx\"target =_ blanktitle =New Window > ^ ]财产。但除非你也调整 IntegralHeight [ ^ ]属性。例如。

 ComboBox3.IntegralHeight =  False  
ComboBox3.MaxDropDownItems = 10



您的要求的第二部分有点奇怪,但只需重置 IntegralHeight = True 即可实现。你必须小心把它放在哪里 - 如果你使用点击事件,例如Dropdown会短暂显示然后再次关闭(不要眨眼或你会错过它!)。这可能是最好的主意

 私有  Sub  ComboBox3_DropDownClosed( ByVal 发​​件人作为系统。对象 ByVal  e  As  System.EventArgs) Handles  ComboBox3。 DropDownClosed  
ComboBox3.IntegralHeight = True
结束


Hi,
There are nearly 50 items in my combo box. I want to load them all to combo but want to display few (max. 10) items only.
Can it be set so that when user clicks the combo, few items are shown, when clicked again, all are displayed?

Thanks

解决方案

To control the number of items displayed in a comboBox you can use the MaxDropDownItems[^] property. But it won't behave the way you expect it to unless you also adjust the IntegralHeight[^] property. E.g.

ComboBox3.IntegralHeight = False
ComboBox3.MaxDropDownItems = 10


The second part of your requirement is a little strange but can be achieved by simply resetting IntegralHeight = True. You have to be careful where to place this - if you use the Click event for example the Dropdown will briefly show then close again (don't blink or you'll miss it!). This is probably the best idea

Private Sub ComboBox3_DropDownClosed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.DropDownClosed
    ComboBox3.IntegralHeight = True
End Sub


这篇关于在组合框中显示几个项目:::: VB.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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