Select a combo-list item

  • Thread starter Thread starter Joachim Granzow
  • Start date Start date
J

Joachim Granzow

Guest
Hello,

ich wish to select the list item of - say - a combo box by way of scrolling throgh the list until the item with the desired number (the ID) is found. The following code did this job for some time:

Public Sub SetList(ByVal lst As Object, ByVal Zahl As Long)
For Each it As Object In lst.Items
If TypeOf it Is ComboListItem Then
If it.zahl = Zahl Then
lst.SelectedItem = it
Exit Sub
End If
End If
Next
End Sub

The list items have the property "zahl" (German for "number").

Most of the time now, however, the code "lst.SelectedItem = it" runs into "System.InvalidCastException": "illegal conversion from string true into double"

How is this possible? "it" and list.Selecteditem are members of the same list "lst", so there cannot be a conversion at all

Continue reading...
 
Back
Top