BoundColumn 属性BoundColumn property

标识多列**ComboBox** 或**ListBox** 中的数据源。Identifies the source of data in a multicolumn ComboBox or ListBox.

语法Syntax

对象BoundColumn[= Variant ]object.BoundColumn [= Variant ]

BoundColumn 属性语法包含以下部分:The BoundColumn property syntax has these parts:

PartPart 说明Description
objectobject 必需。Required. 一个有效的对象。A valid object.
VariantVariant 可选。Optional. 指示已选择 BoundColumn 值。Indicates how the BoundColumn value is selected.

设置Settings

Variant 的设置如下:The settings for Variant are:

Value 说明Description
00 ListIndex 属性的值分配给控件。Assigns the value of the ListIndex property to the control.
1 或更大1 or greater 将指定列中的值分配给控件。Assigns the value from the specified column to the control. 当使用此属性(默认)时,列从 1 开始编号。Columns are numbered from 1 when using this property (default).

备注Remarks

用户选择多列 ListBoxComboBox 中某行时, BoundColumn 属性指出该行中哪个项目保存为控件的值。When the user chooses a row in a multicolumn ListBox or ComboBox, the BoundColumn property identifies which item from that row to store as the value of the control. 例如,如果每行包含 8 个项目并且 BoundColumn 是 3,系统会将当前选定行的第三列中的信息保存为对象的值。For example, if each row contains 8 items and BoundColumn is 3, the system stores the information in the third column of the currently-selected row as the value of the object.

您可以使用 BoundColumnTextColumn 属性向用户显示一组数据但为对象存储不同的关联值。You can display one set of data to users but store different, associated values for the object by using the BoundColumn and the TextColumn properties. TextColumn标识在ComboBox的文本框部分中显示的数据列以及存储在text属性中的值。BoundColumn标识为控件存储的关联数据值的列。TextColumn identifies the column of data displayed in the text box portion of a ComboBox and the value stored in the Text property; BoundColumn identifies the column of associated data values stored for the control.

例如,可以设置多列 ListBox,在第一列中包含假期的名称,在第二列中包含假期的日期。For example, you could set up a multicolumn ListBox that contains the names of holidays in one column and dates for the holidays in a second column. 若要向用户显示假期的名称,可将第一列指定为 TextColumnTo present the holiday names to users, specify the first column as the TextColumn. 若要存储假期的日期,可将第二列指定为 BoundColumnTo store the dates of the holidays, specify the second column as the BoundColumn. 若要隐藏假日的日期, 请将第二列的ColumnWidths属性设置为零。To hide the dates of the holidays, set the ColumnWidths property of the second column to zero.

如果控件绑定数据源BoundColumn 指定的列中的值将存储在 ControlSource 属性中命名的数据源中。If the control is bound to a data source, the value in the column specified by BoundColumn is stored in the data source named in the ControlSource property.

ListIndex 值检索所选行的编号。The ListIndex value retrieves the number of the selected row. 例如,如果要知道所选项目所在的行,可将 BoundColumn 设置为 0,以将所选行的编号指定为控件的值。For example, if you want to know the row of the selected item, set BoundColumn to 0 to assign the number of the selected row as the value of the control. 如果所引用的列表的内容有所变化,请确保检索的是当前值,而不是以前保存的值。Be sure to retrieve a current value, rather than relying on a previously saved value, if you are referencing a list whose contents might change.

ColumnListListIndex 属性都使用从 0 开始的编号方式。The Column, List, and ListIndex properties all use zero-based numbering. 即,第一个项目的值(列或行)为 0;第二个项目的值为 1,依此类推。That is, the value of the first item (column or row) is zero; the value of the second item is one, and so on. 这意味着如果将BoundColumn设置为 3, 则可以使用表达式列 (2) 访问该列中存储的值。This means that if BoundColumn is set to 3, you could access the value stored in that column by using the expression Column(2).

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.