将文本和 ID 值添加到 VB6 组合框 [英] Adding both text and an ID value to a VB6 combobox

查看:29
本文介绍了将文本和 ID 值添加到 VB6 组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用 AddItem 方法添加到我的 VB6 组合框.这有效,但是,我想在下拉列表中显示文本,但我需要传递该文本的 ID.

I am currently trying to add to my VB6 combobox using the AddItem method. This works, however, I want to display text in the drop down but I need to pass the ID of that text.

有没有办法通过使用 AddItem 方法来实现这一点?

Is there a way to accomplish this by using the AddItem method?

推荐答案

由于 ID 不是数字,我没有使用上面的解决方案.

As the ID was not numeric I didn't use the solution above.

我必须创建一个具有desc"和cod"的类型,然后创建该类型的数组.

I had to create a type that had a "desc" and an "cod" and then create an array of that type.

然后我使用下拉列表的 ListIndex(由数组填充)来获取包含 id 的元素值.

I then used the ListIndex of the drop down (populated by the array) to get the element value which contained the id.

Private Type T_arrType
    cod As String
    dsc As String
End Type


dim x as integer
x = cbo.listIndex
msgbox(strArr(x).cod)
msgbox(strArr(x).dsc)

这篇关于将文本和 ID 值添加到 VB6 组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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