I often wonder what the Microsoft .NET CF team was smoking when it created the omission lists for the compact framework – many extremely useful calls were left out for some reason or the other (color picker, anyone?).

ComboBox objects usually contain a list of different unique strings – the little routine below implements the behaviour desktop developers find in the .FindString method:

Private Function findItem(ByVal cmb As System.Windows.Forms.ComboBox, ByVal text As String)
Dim index As Integer
For index = 0 To cmb.Items.Count - 1 'bc of weird beh index = index
If cmb.Items.Item(index).ToString = text Then
findItem = index
Exit Function
End If
Next
findItem = -1
End Function

As usual: feel free to do whatever you feel like with this code!


Related posts:

  1. Read multiple bytes from a StreamReader
  2. Create Numeric text boxes with .NET CF
  3. HTC TyTN 2 – fix TouchFLO after installing WM 6.1
  4. HTC Diamond, Velocity Micro devices delayed
  5. Microsoft’s Marketplace DRM cracked