Smart (incremental) Combo Box data entry 
Author Message
 Smart (incremental) Combo Box data entry

I would like to convert the VB6 code below to .Net  (or other code already
working in .Net)
I would appreciate any suggestions on substitution code for the Windows API
message call and
substitutions for "Screen.ActiveControl".  It is partially convered at this
point.  Thanks. Dean


Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd
As Long, _

ByVal wMsg As Long, _

ByVal wParam As Long, _

ByVal lParam As Any) As Long

Const CB_ERR = -1


Public Sub IncrLookup(ByVal ky As Integer)



'::: Performs incremental matching during ComboBox keyin :::'

'::: To use, place this line in the combo box KeyPress event: :::'

'::: IncrLookup {comboname}, KeyAscii :::'


'::: Passed: :::'

'::: ky := the ascii keystroke value :::'



Dim str As String, lng As Long

Dim cbo As ComboBox


If TypeOf Screen.ActiveControl Is ComboBox Then

cbo = Screen.ActiveControl

If cbo.DropDownStyle < 2 Then

' Build the search string

str = Left$(cbo.Text, cbo.SelectionStart) & ky.ToString


' Now search the combobox for the string

lng = SendMessage((cbo.hWnd), CB_FINDSTRING, -1, ByVal str)


' Was the string found in the list?

If l <> CB_ERR Then

' Yes, so we set the ListIndex and highlight the text

With cbo

    .ListIndex = lng

    .Text = .List(lng)

    .SelectionStart = Len(str)

    .SelectionLength = Len(.Text)

End With

ky = 0

End If


End If

End If

End Sub

Wed, 15 Sep 2004 13:48:48 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Highlighting data in the text portion of a combo box and overwriting it upon data entry

2. Problem with Matched entry property of data bound combo box

3. HELP: Combo Box Incremental Search

4. Incremental search combo box

5. Incremental search in combo box

6. enter data in a combo box based on value from another combo box

7. Combo Box like Data Bound Combo Box?

8. Copy Last entry on Combo Box to Text Box

9. smart search in combo or list boxes (please help)

10. Smart Searching in Combo boxes.

11. Smart Combo Box

12. Combo Box That Adds Typed Entry to List


Powered by phpBB® Forum Software