选择后如何在ComboBox中显示第二列? [英] How to display second column in ComboBox after selection?

查看:98
本文介绍了选择后如何在ComboBox中显示第二列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以点击我的ComboBox并查看Column1和Column2的值,但是在我点击ComboBox后,Column1中的值总是会显示,我想要的值是显示第2列。

我试过这个:

        With ComboBox2
            .Value = "None"
            .ColumnHeads = True
            .ColumnCount = 2
            .ColumnWidths = "50;100"
            .RowSource = "SetupQuestions!A42:B48"
            .BoundColumn = 2
        End With


没有像我想象的那样设置值。

That didn't set the value as I thought it would.

我试过这个:

Private Sub ComboBox2_AfterUpdate()
    ComboBox2.Value = ComboBox2.Column(2)
End Sub


没有像我想象的那样设置值。

That didn't set the value as I thought it would.

如何在选择后强制ComboBox在Column2中显示值?

How can I force the ComboBox to display the value in Column2 after a selection is made?

这是一个屏幕截图。

我想在ComboBox中看到'Campaign Name',但我看到的只有1。

I want to see 'Campaign Name' in the ComboBox, but all I see is 1.

我的书

推荐答案

 组合框的文本框部分显示宽度大于0的第一列的值。因此,要显示第二列,请将第一列的宽度设置为0.

The text box part of a combo box displays the value of the first column whose width is larger than 0. So to display the second column, set the width of the first column to 0.

哪个列包含组合框的值由BoundColumn属性确定。如果将其设置为1(默认值) t),组合框的值是其第一列的值(即使该列因其宽度为0而被隐藏)。如果将
设置为2,则组合框的值是其第二列的值等。如果将BoundColumn设置为0,则组合框的值等于所选的从零开始的索引item(ListIndex)。

Which column contains the Value of the combo box is determined by the BoundColumn property. If you set it to 1 (the default), the Value of the combo box is the value of its first column (even if that column is hidden because its width is 0). If you set it to 2, the Value of the combo box is the value of its second column, etc. And if you set BoundColumn to 0, the Value of the combo box equals the zero-based index of the selected item (the ListIndex).


这篇关于选择后如何在ComboBox中显示第二列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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