R
Randy
I'm looking for an easy way to find the value member of an object in a
control. I have an ArrayList of a simple class with two properties. One
property is "Id" and the other is "CompName" (both stings). On my form I
have a CheckListBox and I bind the ArrayList of Company's like so.
Clb.DisplayMember = "CompName"
Clb.ValueMember = "Id"
Clb.DataSource = alCompany
I have a second ArrayList with stings that match the Id of some of the
companies that I want to set the check state. But with the folling code I
always get a -1 index. Is there another way except looping through the
entire CheckListBox for every Id in the Second ArrayList? The Obj.ToString
is holding a valid Id, but its not finding it.
Dim obj as Object
Dim intLoop as Integer
For each obj in alCheckTheseId
intLoop = clb.ValueMemeber.IndexOf(Obj.ToString)
if intLoop > -1 Then
clb.SetItemChecked(intLoop, True)
end if
Next
MANY THX,
-Randy
control. I have an ArrayList of a simple class with two properties. One
property is "Id" and the other is "CompName" (both stings). On my form I
have a CheckListBox and I bind the ArrayList of Company's like so.
Clb.DisplayMember = "CompName"
Clb.ValueMember = "Id"
Clb.DataSource = alCompany
I have a second ArrayList with stings that match the Id of some of the
companies that I want to set the check state. But with the folling code I
always get a -1 index. Is there another way except looping through the
entire CheckListBox for every Id in the Second ArrayList? The Obj.ToString
is holding a valid Id, but its not finding it.
Dim obj as Object
Dim intLoop as Integer
For each obj in alCheckTheseId
intLoop = clb.ValueMemeber.IndexOf(Obj.ToString)
if intLoop > -1 Then
clb.SetItemChecked(intLoop, True)
end if
Next
MANY THX,
-Randy