在下拉列表中获取所选项目的位置(数量) [英] Get position (in number) of selected item in dropdown list

查看:137
本文介绍了在下拉列表中获取所选项目的位置(数量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下拉列表中,我有几个项目。当我选择一个项目时,我可以在列表中获得该项目的位置吗?

In a dropdown list I have a few items. Can I, when I select an item, get the position of that item in the list as a number?

推荐答案

如果你是使用列表或组合框, ListIndex 似乎是你之后。

If you are using a list or combo box, ListIndex would seem to be what you are after.

VB帮助 ListIndex 属性:返回或设置列表框或组合框中当前选定项目的索引编号。读/写长备注。

VB Help for ListIndex property: Returns or sets the index number of the currently selected item in a list box or combo box. Read/write Long. Remarks. You cannot use this property with multiselect list boxes.

如果没有选择, ListIndex 的值为 -1 。如果内存服务,它是一个基于零的索引。

If nothing is selected, ListIndex's value is -1. If memory serves, it is a zero based index.

ListIndex 不能在设计时设置,因此它不是在属性窗口中列出。

ListIndex cannot be set at design time so it is not listed in the properties window.

输入代码时,键入列表框名称,然后点击,编辑器显示所有可用的属性。向下滚动列表,注意任何有趣的东西,然后查找它们。

When entering your code, type the list box name then dot and the editor displays all the available properties. Scroll down the list, note any that look interesting, then look them up.

这篇关于在下拉列表中获取所选项目的位置(数量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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