我知道这是一项简单的任务,但我无法设置ComboBox.SelectedItem。假设我有以下代码....
Class InnerClass
Public InnerProperty As String
End Class
Class [Class]
Public [Property] As String
Public InnerClass As InnerClass
End Class
Private Sub Form_Load(ByVal sender As Object,ByVal e as EventArgs)
Dim cls as New [Class]
Dim innerCls as New InnerClass
Dim list as New BindingList(Of InnerClass)
list.Add(New InnerClass)
list.Add(New InnerClass)
list.Add(New InnerClass)
cls.InnerClass=list.Items(2)
ComboBox1.DataSource=list
ComboBox1.DisplayMember="InnerProperty"
ComboBox1.DisplayValue="InnerProperty"
ComboBox1.DataBindings.Add("SelectedItem",cls,"InnerClass") 'always displays 1st item
list.Add(innerCls)
ComboBox1.SelectedItem=innerCls 'No effect
End Sub
如何使ComboBox1.SelectedItem正确绑定到 [Class].InnerProperty?如何手动设置ComboBox1.SelectedItem ?