ComboBox值发生了变化 [英] ComboBox values getting changed
问题描述
关于我昨天的问题(如何从SQL数据表中填充组合框 [ ^ ])我有一个新问题。
我的ComboBox填充了我的测试数据库中的3个条目。如果我点击ComboBox,我会得到3个条目,如果我没有选择一个,我只是再次点击ComboBox,它关闭,我可以无限重复这个广告...这就像我期望的那样。
如果我然后点击ComboBox并选择其中一个,让我们说中间的一个,DropDown关闭,选择在ComboBox中,再次,如我希望。
然而,如果我再次单击ComboBox(让我们假设我的用户选择了错误的选项),我做的选择现在是第一个条目,原始的第一个条目已经消失,第二个条目,我选择的条目,已被替换为文本System.Data.DataRowView(如果我将ValueMember设置为数据集中的名称)或者如果我将ValueMember设置为数据集中的ID,我的选择,当我重新打开ComboBox时,突出显示,仍然在第二位,但第一个条目已经消失,已被数字2替换...我想一想sitioning可能取决于DatsTable的排序。
如果我取消并重新运行,一切都恢复正常,所以没有任何东西真正被更新。
这是我的代码,Tejas,例如......
< span class =code-keyword>公开 类 KAmail_Form1
私有 Sub KAmail_Form1_Load(sender As System。 Object ,e As System.EventArgs)句柄 MyBase .Load
Me .LeaguesTableAdapter.Fill( Me 。 DB_KAmailDataSet.Leagues)
KAmail_ComboBox1.SelectedIndex = -1
KAmail_ComboBox2.SelectedIndex = 0
结束 Sub
私有 Sub KAmail_Button1_Click(发件人作为系统。对象,e As System.EventArgs)句柄 KAmail_Button1.Click
结束 Sub
私有 Sub KAmail_Button2_Click(发件人作为系统。对象,e As System.EventArgs)句柄 KAmail_Button2.Click
我 .Close()
结束 Sub
结束 类
我的方式不同,所以可以关闭/删除这个问题/主题。
As a follow on to my question of yesterday (How do I Populate a Combobox from a SQL Datatable[^]) I have a new question.
My ComboBox is populated with the 3 entries from my test Database. If I click on the ComboBox I get the 3 entries as I would expect, if I don't select one and I just click on the ComboBox again, it closes and I can repeat this ad infinitum ... this is as I would expect.
If I then click on the ComboBox and Select one of them, let's say the middle one, the DropDown closes and the Selection is in the ComboBox, again, as I would expect.
However, if I then click on the ComboBox again (let's assume my User has Selected the wrong option), the Selection I made is now the first entry, the original first entry has gone, and the second entry, the one I Selected, has been replaced with either the text "System.Data.DataRowView" (If I have the ValueMember set to the Name from the Dataset) or if I have the ValueMember set to the ID from the Dataset, my Selection, when I re-open the ComboBox, is highlighted, still in second place, but the first entry is gone and has been replaced by the Number "2" ... I think the positioning is probably down to Sorting of the DatsTable.
If I cancel and rerun, everything is back to normal so nothing is really being Updated.
This is my code, Tejas, such as it is ...
Public Class KAmail_Form1 Private Sub KAmail_Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.LeaguesTableAdapter.Fill(Me.DB_KAmailDataSet.Leagues) KAmail_ComboBox1.SelectedIndex = -1 KAmail_ComboBox2.SelectedIndex = 0 End Sub Private Sub KAmail_Button1_Click(sender As System.Object, e As System.EventArgs) Handles KAmail_Button1.Click End Sub Private Sub KAmail_Button2_Click(sender As System.Object, e As System.EventArgs) Handles KAmail_Button2.Click Me.Close() End Sub End Class
I have done this differently, so this question / topic can be closed / deleted.
这篇关于ComboBox值发生了变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!