Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extend VB's DBCombo box... ?

Status
Not open for further replies.

chernandez2000

Programmer
Nov 3, 2001
22
0
0
US
Hi all,

I am trying to extend the normal way the DBCombo box works as follows:

The DBCombo is currently attached to a field in a database, so it is populated with, for example, last names. I am using dblExtendedMatching under the Match Entry property. So the names automatically complete. Thats cool. But I want to highlight the part of the name that is autocompleted, and also if the user enters a letter that isnt there, then no longer highlight anything.

So if "Smith" is a last name in the database... as the user types "S" then "mith" would appear and be highlighted... then if the next letter the user enters is "a", then since there is no "Sa..." names in the database, the user would see "Sa" without any highlights.

Excuse the long post, but I wanted to explain it. I have a feeling Windows API calls will be involved.

Anyone point me in the right direction?

Thanks!

Conrad
 
Hi,

You can use the CB_FINDSTRING or CB_FINDSTRINGEXACT message to search a combobox.

Use something like this and type "b":

[tt]Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_FINDSTRING = &H14C

Private Sub Combo1_Change()
Combo1.ListIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, Combo1.Text)
End Sub

Private Sub Form_Load()
Dim I As Integer

For I = 1 To 20000
Combo1.AddItem I
Next
Combo1.AddItem "Bla"
End Sub[/tt]

LuCkY
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top