|
-
Nov 9th, 2000, 09:40 AM
#1
Thread Starter
Lively Member
I am looking for a combo/list control that will do incremental searches like Access' control does. The data combo in VB does it, but it does not display the characters as the user enters them. I find the incremental search in vb's control to be kind of confusing for users. I have been using the True DBGrid control, and like it a lot. I went to Apex's site, and looked at their True DBList controls. They do not have that much info on their site about it though. Have any of you used these controls, or would you recommend another control from someone else? Please comment on any problems/concerns you have with Apex's controls.
Thanks.
-
Nov 9th, 2000, 01:02 PM
#2
I've used Apex's Datagrid control and I liked it alot. As for the Access like search in a combo. Just write the code yourself, it'd probably be easier. Here is a sample for a normal combo named cbo
Code:
Private Sub cbo_Keyup(KeyCode As Integer, Shift As Integer)
'ignore if it is backspace or delete
If KeyCode <> 46 Or KeyCode <> 8 Then
'set max of items
cMax = cbo.ListCount
For x = 1 To cMax
'figure the length of what is typed so far
iLen = Len(cbo.Text)
If iLen > 0 Then
'compare what is typed to items in combo
'switch them all to one case so case wont matter
If UCase(cbo.Text) = UCase(Left(cbo.List(x - 1), iLen)) Then
'fill in the word if it matches
cbo.Text = cbo.List(x - 1)
'select the filled in part so the user can type over if it isn't right
cbo.SelStart = iLen
cbo.SelLength = Len(cbo.Text) - iLen
End If
End If
Next x
End If
End Sub
It would actually be easier if you were using a datacombo because you can use the filter method.
-
Nov 9th, 2000, 03:37 PM
#3
Thread Starter
Lively Member
Thanks for the code! I am using a datacombo so it does not work. I can not find the filter method for the datacombo. Can you post some code for the datacombo please.
Thanks!
-
Nov 9th, 2000, 06:59 PM
#4
Almost Works
Well here is the code for a datacombo but there is a problem with it hopefully someone else can figure it out.
Code:
Private Sub dcbo_KeyUp(KeyCode As Integer, Shift As Integer)
'the datacombo must already be bound to a rowource and have a listfield
'for the example the rowsource is ado and the listfield is LastName
'ignore if it is backspace or delete
If KeyCode <> 46 And KeyCode <> 8 Then
'search list using filter
ado.Recordset.Filter = "LastName Like '" & dcbo.Text & "*'"
'see if there are any matches
If ado.Recordset.RecordCount > 0 Then
'figure the length of what is typed so far
iLen = Len(dcbo.Text)
'fill in the word if it matches
dcbo.Text = ado.Recordset!LastName
'for some reason it selects the whole word regardless of the code below
'select the filled in part so the user can type over if it isn't right
dcbo.SelStart = iLen
dcbo.SelLength = Len(dcbo.Text) - iLen
End If
End If
End Sub
The only problem is that when the text property is set to something that matches in the list it automatically selects the whole word ignoring me selstart and selength commands. So it will find a match but the user wont be able to continue typing if there is a match. You may want to just populate a normal combo with data unless someone figures out a work around. I'll keep trying, but I can't right now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|