【发布时间】:2019-10-11 10:31:20
【问题描述】:
我遇到了一些问题,我想知道如何解决这些问题。 是否可以在不知道变量名称的情况下从匿名类型的对象中获取值?
我有 2 个组合框:
With combobox1
.ItemsSource = list1
.DisplayMemberPath = "Name"
.SelectedValuePath = "Age"
End With
With combobox2
.ItemsSource = list2
.DisplayMemberPath = "Address"
.SelectedValuePath = "Number"
End With
我想从选定的组合框中获取值,但我想要一个普通的子:
Dim list As New List(Of Object)
Private Sub FilterCombobox(combobox as Combobox)
For Each item In combobox.Items
list.Add(New With {.Value = item.????,
.Display = item.????})
Next
End Sub
如何在 For Each 上调用 DisplayMemberPath 和 SelectedValuePath?
.Value = item.SelectedValuePath
.Display = item.DisplayMemberPath
我想访问这些值,但如您所见,项目名称不同。 我需要动态访问这些数据。
【问题讨论】: