在组合框中显示几个项目:::: VB.Net [英] Displaying few items in combo box :::: 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 resettingIntegralHeight = True
. You have to be careful where to place this - if you use theClick
event for example the Dropdown will briefly show then close again (don't blink or you'll miss it!). This is probably the best ideaPrivate Sub ComboBox3_DropDownClosed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.DropDownClosed ComboBox3.IntegralHeight = True End Sub
这篇关于在组合框中显示几个项目:::: VB.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!