更新时间:2023-11-28 20:45:34
我将假设您已将列表框绑定到数据表.如果是这样,我本人就无法使用SelectedValue.
我发现有效的方法是使用以下方法来获取选定的值:
I''m going to assume that you have the listbox bound to a datatable. If so, I''ve had trouble with the SelectedValue myself.
What I''ve found works is to use the following to get the selected value:
Listbox.SelectedItems(X)(Listbox.ValueMember)
只需将"Listbox"替换为控件的名称,将"X"替换为要获取其值的所选项目的索引.
如果一次只允许1个选择,则可以将"X"硬编码为0.
祝你好运!
Just replace "Listbox" with the name of your control, and "X" with the index of the selected item you''re getting the value for.
If you''re only allowing 1 selection at a time, then you can hardcode the "X" as 0.
Good luck!
如果您有一个字符串,并且想要从中获取值,可以查看 ^ ]并使用convert方法.
If you have a string and you want to get the value out of that, you can have a look at this[^] and use the convert method.
我为您提供了一种最简单的方法..!你会喜欢的.
.
I have a one gud Simplest way for you..!! you will love this.
.
Dim i As Integer
Dim item(ListBox1.SelectedItems.Count - 1) As String
For Each item(i) In ListBox1.SelectedItems
ListBox2.Items.Add(item(i).ToString())
i += 1
Next
对您有帮助吗?
does it help u?