问题描述
你好,
我正在围绕这个问题四处走动,我希望有人可以帮助我。
我有一个列表框是从SQL Server数据库填充,包含大约600个项目,所有字符串。
我在同一表单上有一个文本框,我想显示哪个项目被选中。
在''OnSelectedIndexChanged''事件中,我需要具有文本框更新的代码到列表框中当前选择的任何值。
如果我使用代码:
TextBox1.Text = ListBox1.SelectedItem.toString
它会在文本框中显示不正确的项目。
如果我使用带有以下代码的数据行视图:
Dim drv As DataRowView = lBoxCP.SelectedItem
txtCPMain.Text = drv(" STR_CUTTING_PERMIT")
它运作良好,但点击几个不同的项目后,文本框开始显示不正确的项目。
SelectionMode设置为一。
有什么建议吗?
谢谢,
Amber
Hello,
I''m going around in circles with this problem and I hope someone can help me.
I have a listbox that is populated from a SQL Server database, with about 600 items, all strings.
I have a textbox on the same form, where I want to display which item is selected.
In the ''OnSelectedIndexChanged'' event, I need code that has the textbox update to whatever value is currently selected in the listbox.
If I use the code:
TextBox1.Text = ListBox1.SelectedItem.toString
it diplays the incorrect item in the textbox.
If I use a datarow view with the following code:
Dim drv As DataRowView = lBoxCP.SelectedItem
txtCPMain.Text = drv("STR_CUTTING_PERMIT")
It works quite well, but after clicking several different items, the text box starts showing incorrect items.
SelectionMode is set to One.
Any suggestions?
Thanks,
Amber
推荐答案
这篇关于文本框和列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!