473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Incremental Key Seasrch, ComboBox

I am trying to duplicate this functionality from VB6:

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 cboSunday_KeyPress(KeyAscii As Integer)
Call ComboIncrementalSearch(cboSunday, KeyAscii)
End Sub

Public Sub ComboIncrementalSearch(cbo As ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5

If (KeyAscii < 32 Or KeyAscii 127) Then Exit Sub
If (Timer - dTimerLast) < MAX_KEYPRESS_TIME And hWndLast = cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
nRet = SendMessage(cbo.hWnd, CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub

so that essentially as you type in keys in a combobox, it brings you
automatically to the closest matching item. Anyone have any example code for
that?

Thanks in advance.

Ed


May 10 '07 #1
3 1459
If you are using .NET 2.0 take a look at the AutoCompleteMode,
AutoCompleteSource and AutoCompleteCustom properties. You don't have to use
PInvoke at all.

For a sample:
http://www.c-sharpcorner.com/UploadF...ompletion.aspx

Hope this helps.

"EdB" wrote:
I am trying to duplicate this functionality from VB6:

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 cboSunday_KeyPress(KeyAscii As Integer)
Call ComboIncrementalSearch(cboSunday, KeyAscii)
End Sub

Public Sub ComboIncrementalSearch(cbo As ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5

If (KeyAscii < 32 Or KeyAscii 127) Then Exit Sub
If (Timer - dTimerLast) < MAX_KEYPRESS_TIME And hWndLast = cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
nRet = SendMessage(cbo.hWnd, CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub

so that essentially as you type in keys in a combobox, it brings you
automatically to the closest matching item. Anyone have any example code for
that?

Thanks in advance.

Ed

May 11 '07 #2
Thank you Siva, that works perfectly.

"Siva M" wrote:
If you are using .NET 2.0 take a look at the AutoCompleteMode,
AutoCompleteSource and AutoCompleteCustom properties. You don't have to use
PInvoke at all.

For a sample:
http://www.c-sharpcorner.com/UploadF...ompletion.aspx

Hope this helps.

"EdB" wrote:
I am trying to duplicate this functionality from VB6:

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 cboSunday_KeyPress(KeyAscii As Integer)
Call ComboIncrementalSearch(cboSunday, KeyAscii)
End Sub

Public Sub ComboIncrementalSearch(cbo As ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5

If (KeyAscii < 32 Or KeyAscii 127) Then Exit Sub
If (Timer - dTimerLast) < MAX_KEYPRESS_TIME And hWndLast = cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
nRet = SendMessage(cbo.hWnd, CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub

so that essentially as you type in keys in a combobox, it brings you
automatically to the closest matching item. Anyone have any example code for
that?

Thanks in advance.

Ed


May 11 '07 #3
Glad to know it helped.

"EdB" wrote:
Thank you Siva, that works perfectly.

"Siva M" wrote:
If you are using .NET 2.0 take a look at the AutoCompleteMode,
AutoCompleteSource and AutoCompleteCustom properties. You don't have to use
PInvoke at all.

For a sample:
http://www.c-sharpcorner.com/UploadF...ompletion.aspx

Hope this helps.

"EdB" wrote:
I am trying to duplicate this functionality from VB6:
>
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 cboSunday_KeyPress(KeyAscii As Integer)
Call ComboIncrementalSearch(cboSunday, KeyAscii)
End Sub
>
Public Sub ComboIncrementalSearch(cbo As ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5
>
If (KeyAscii < 32 Or KeyAscii 127) Then Exit Sub
If (Timer - dTimerLast) < MAX_KEYPRESS_TIME And hWndLast = cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
nRet = SendMessage(cbo.hWnd, CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub
>
so that essentially as you type in keys in a combobox, it brings you
automatically to the closest matching item. Anyone have any example code for
that?
>
Thanks in advance.
>
Ed
>
>
>
>
>
>
May 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jane | last post by:
HI, I had a question on incremental backup. We had an incremental backup every weekend. We did full backup every other week. That is one week incremental + full , the other week is...
1
by: Jimmy Chen | last post by:
Recently I've done a db2 backup and restore/recovery, but the process for recovering the database was different than what I thought to be. here is what I did: DB2 is set in online mode -...
3
by: apple | last post by:
UDB v8 fp 6a on AIX 5.1.0.0 Below is a manual incremental recover from compressed backup datasets. With external compress backup datasets, can it be coded to do an automatic incremental recover?...
0
by: Willem | last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a nifty little procedure that - whenever you compact you db you get an incremental backup copy. Given that you have a table with...
14
by: Christopher Weaver | last post by:
What's the best way to go about an incremental search within a ComboBox? I've looked at the FindString method, but before I go down that road, I'm wondering if there's a component out there that...
6
by: Rudy Ray Moore | last post by:
I work with a multi-project workspace. One project (the "startup" project) has a "Configuration Type" of "Application (.exe)". The other 40 projects have a "Configuration Type" of "Static Library...
3
by: Alex Shturm | last post by:
Hi, I am trying to activate incremental link using VC7 (.NET 2003) on a pretty big project (executable size is more than 100Mb, and it gets linked from several dozen of libraries and object...
1
by: Kirk_Kelly | last post by:
Anybody know how to get the combobox to do a incremental search in vb.net window forms?
8
by: Bern McCarty | last post by:
We have a large mixed dll that I can never seem to get to link incrementally. Below is the console output. For simplicity I've eliminated some stuff that we normally do when we really link this...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.