组合框可以在其textbox部分提供多于一列吗? [英] Can a combobox present more then one column on its textbox part?
问题描述
我在我的组合框中有一个两列列表,当我使用下拉列表选择其中的一个项目时,它存储(我在组合框的textbox部分看到的)只有我选择的值根据绑定列在右侧或左侧列)
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。在文本框中我想要:丹尼尔·史密斯(不只是丹尼尔,或史密斯他们自己)
For example: [column1] Daniel [column2] Smith. And in the textbox I want: Daniel Smith (and not just Daniel, or Smith on they're own)
推荐答案
describe在理论上是可能的,但有限制。
What you describe is theoretically possible, but with restrictions.
即使您没有要求,这里是我的想法:
正如这里所述,您可以更改ComboBox的 text
,而不更改其值
。这允许您存储基础值,同时将两个列显示在一个列中。
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
并更改文本
属性,如下所示: / p>
Listen on the SelectedIndexChanged Event
and change the text
property as follows:
Sub ComboBox1_SelectedIndexChanged()
ComboBox1.Text = ComboBox1.Column(0) & "-" & ComboBox1.Column(1)
End Sub
例如。)现在无法测试,但在.Net中,您可以使用 CType
显式转换 sender
(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.
这篇关于组合框可以在其textbox部分提供多于一列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!