C
Crazy Cat
Hi all,
I have combobox that is bound to a custom object collection thusly
Dim collection As List(Of StructureType) =
StructureType.FindStructureTypes(SharedObjects.StructureTypes,
DropDownListStructure.SelectedValue, DropDownListType.SelectedValue)
DropDownListSubType.DataSource = collection
DropDownListSubType.DisplayMember = "StructureName"
The method FindStructureTypes is a shared method that returns a list
of StructureType objects filtered by the value in another combobox.
When I set the SelectedItem of the ComboBox programatically to a
StructureType object the selecteditem never changes.
Suspecting that the SelectedItem is not found in the combobox's
datasource I put in a piece of code to print the index of the object
in the collection using List(Of StructureType).IndexOf. As suspected I
get a -1.
When I run this code in debug and look at the collection (15 objects
in all) in QuickWatch I can see that the object is in the collection.
These objects are retrieved from a database and have a unique ID
property. The StructureType object that I am setting in the combobx
comes from the same list as the datasource using a method that
retrieves just one item by ID.
Has anyone seen this before, or am I missing something about
SelectedItem?
PLEASE HELP
Thanks
I have combobox that is bound to a custom object collection thusly
Dim collection As List(Of StructureType) =
StructureType.FindStructureTypes(SharedObjects.StructureTypes,
DropDownListStructure.SelectedValue, DropDownListType.SelectedValue)
DropDownListSubType.DataSource = collection
DropDownListSubType.DisplayMember = "StructureName"
The method FindStructureTypes is a shared method that returns a list
of StructureType objects filtered by the value in another combobox.
When I set the SelectedItem of the ComboBox programatically to a
StructureType object the selecteditem never changes.
Suspecting that the SelectedItem is not found in the combobox's
datasource I put in a piece of code to print the index of the object
in the collection using List(Of StructureType).IndexOf. As suspected I
get a -1.
When I run this code in debug and look at the collection (15 objects
in all) in QuickWatch I can see that the object is in the collection.
These objects are retrieved from a database and have a unique ID
property. The StructureType object that I am setting in the combobx
comes from the same list as the datasource using a method that
retrieves just one item by ID.
Has anyone seen this before, or am I missing something about
SelectedItem?
PLEASE HELP
Thanks