组合框可以在其文本框部分显示多于一列吗? [英] Can a combobox present more then one column on its textbox part?
问题描述
我的组合框中有一个两列列表,当我使用下拉列表选择其中的一项时,它仅存储(我在组合框的文本框部分看到的内容)我选择的值(无论是根据 boundcolumn 在右列或左列的那个)
I have a two column list in my combobox and when I choose one of the items in it using the drop down list, it stores (what I see in the textbox part of the combobox) only the value I selected (wether it's the one on the right or left column according to boundcolumn)
我的问题是:有没有办法在组合框的文本框部分存储(或呈现——这是我的目标),同时选中一行的两列?
My question is: Is there a way to store(or present-that is my goal) in the textbox part of the combobox, both of the columns of one row selected?
例如:[column1] Daniel [column2] Smith.在我想要的文本框中:Daniel Smith(不仅仅是 Daniel,或者他们自己的 Smith)
For example: [column1] Daniel [column2] Smith. And in the textbox I want: Daniel Smith (and not just Daniel, or Smith on they're own)
推荐答案
你所描述的在理论上是可能的,但有限制.
What you describe is theoretically possible, but with restrictions.
即使你没有要求,我的想法来了:
如此处所述,您可以更改您的ComboBox 的 text
不改变它的 value
.这允许您存储"基础值,同时将两列显示为一列.
Like described here you can change your ComboBox's text
without changing its value
. This allows you to 'store' the underlying value while displaying both columns in one.
聆听 SelectedIndexChanged Event
并更改 text
属性如下:
Sub ComboBox1_SelectedIndexChanged()
ComboBox1.Text = ComboBox1.Column(0) & "-" & ComboBox1.Column(1)
End Sub
(这只是一个基本的例子.)现在无法测试,但在 .Net 中你可以使用 CType
显式转换 sender
ComboBox 变量的参数并以这种方式访问它.
(This is only a basic example.) Can't test it right now, but in .Net you can use CType
to explicitly convert the sender
argument to a ComboBox variable and access it this way.
Boundcolumn
属性不能更改为多个值.您可以尝试使用 VbTab
作为文本字段中的分隔符,但我不确定它会如何显示.
The Boundcolumn
property can't be changed to multiple values. You can try to use VbTab
as a delimiter in the text field but i'm not sure how it will appear.
不要忘记默认值.我认为您的文本字段也应该在用户第一次点击列表之前之前显示两列.
Don't forget the default values. I think your Text field should show both columns before the user clicked on the list the first time, too.
这篇关于组合框可以在其文本框部分显示多于一列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!