VB.NET Combobox.SelectedValue [英] VB.NET Combobox.SelectedValue
问题描述
有没有人听说过你不能将Combobox.SelectedValue设置为1的问题?我有一个带有Combobox的VB.NET 2005数据输入表单。此Combobox是从Access中的查找表填充的。我已经验证了Combobox有适当的ValueMembers和DisplayMembers,它们与查找表中的数据相匹配。
Has anyone heard of a problem where you can't set the Combobox.SelectedValue to 1? I have a VB.NET 2005 data entry form with a Combobox on it. This Combobox is populated from a lookup table in Access. I've already verified that the Combobox has the appropriate ValueMembers and DisplayMembers, and they match up with the data in the lookup table.
我可以为表中的每个值设置Combobox.SelectedValue属性,除了1.我甚至尝试过硬编码... Combobox.SelectedValue = 1 。 ..那没用。 Combobox.SelectedValue = 2 工作正常。是的,我确实在查找表中有对应于1和2的记录。
I can set the Combobox.SelectedValue property for every value in the table except for 1. I even tried hardcoding it...Combobox.SelectedValue = 1...that didn't work. Combobox.SelectedValue = 2 works fine. And yes, I do have records in the lookup table corresponding to both 1 and 2.
我在Combobox的SelectedIndexChanged事件中使用了以下代码行...
I used the following line of code in the SelectedIndexChanged event of the Combobox...
Messagebox.Show(Me.ComboBox.SelectedValue)
...当我选择第一条记录时,它确实显示了消息框中的SelectedValue为1。
...When I select the first record, it does indeed show a SelectedValue of 1 in the messagebox.
推荐答案
当我将selectedvalue设置为组合框中的第一个项目时,我遇到了同样的问题。你有没有解决这个问题?
I have the same problem when I set the selectedvalue to the first item in the combobox. Have you solved this yet?
这篇关于VB.NET Combobox.SelectedValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!