Don't worry, I've sorted this. However, I've created a new control to do it; wack the following into a new class
Code:
Public Class AutoCompleteComboBox
Inherits System.Windows.Forms.ComboBox
Protected _AutoCompleteEnabled As Boolean = True
<System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Enables or disables the autocompletion functionality")> _
Public Property AutoCompleteEnabled() As Boolean
Get
Return _AutoCompleteEnabled
End Get
Set(ByVal Value As Boolean)
_AutoCompleteEnabled = Value
End Set
End Property
Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
' only do something if autocomplete is enabled...
If _AutoCompleteEnabled = True Then AutoComplete(e)
End Sub
Private Sub AutoComplete(ByVal e As Windows.Forms.KeyEventArgs)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String
'Allow select keys without Autocompleting
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
Return
End Select
'Get the Typed Text and Find it in the list
sTypedText = Text
iFoundIndex = FindString(sTypedText)
'If we found the Typed Text in the list then Autocomplete
If iFoundIndex >= 0 Then
'Get the Item from the list (Return Type depends if Datasource was bound
' or List Created)
oFoundItem = Items(iFoundIndex)
'Use the ListControl.GetItemText to resolve the Name in case the Combo
' was Data bound
sFoundText = GetItemText(oFoundItem)
'Append then found text to the typed text to preserve case
sAppendText = sFoundText.Substring(sTypedText.Length)
Text = sTypedText & sAppendText
'Select the Appended Text
SelectionStart = sTypedText.Length
SelectionLength = sAppendText.Length
End If
End Sub
End Class
I'd just like to say none of it is my own work apart from a tiny amount of combining of code -the autocomplete procedure is from
http://www.thecodeproject.com/vb/net...e_combobox.asp by Daryl, the 'autocompleteenabled' idea from
http://www.dotnetforums.net/t81380.html by Plausibly Damp.