我有一堂课,如下所示:
Public Class parameters
Public Property test As String
Public Property test_type As String
Public Property user_test_name As String
Public Property meas As String
Public Property spec As String
...etc
End Class
我列出了我从某个地方的 csv 导入的对象。列表中的 user_test_name 被发送到列表框:
For Each parameters In param
' MsgBox(parameters.user_test_name)
ListBox1.Items.Add(parameters.user_test_name)
Next
现在,当用户从列表中选择某些内容时,我希望该特定 user_test_name 对象的其余属性填充到应用程序的某些文本/组合框中。这是我如何获取所选内容的方法。
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim selected_name As String = ListBox1.SelectedItem()
' MsgBox(selected_name)
find_object_by_user_test_name(selected_name)
End Sub
现在我很难从列表中找到具有 selected_name 的对象并使用它的属性来填充 text.combo 框。我尝试了以下没有成功:
Public Sub find_object_by_user_test_name(ByVal description)
MsgBox(description)
Dim matches = From parameters In param
Where parameters.user_test_name = description
Select parameters
' MsgBox(matches)
' MsgBox(matches.user_test_name)
TextBox1.Text = matches.test
TextBox2.Text = matches.test_name
etc,,, on and on
' populate_area(matches)
End Sub