473,320 Members | 2,111 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,320 software developers and data experts.

Incremental Search

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 would serve the same purpose
more easily.
Nov 17 '05 #1
14 6409
Do you mean autocompletion, where you move down the combo box as the
user types successive characters until they find the correct entry?

Search this newsgroup for "combobox" and "autocomplete". You should
find pointers to some implementations.

Nov 17 '05 #2
"autocompletion" is another way of puting it, yes. I've just finished
downloading over 9,000 messages from this newsgroup and couldn't find a
single one that contained combobox and autocomplete. Seemed like a good
idea to me too.
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Do you mean autocompletion, where you move down the combo box as the
user types successive characters until they find the correct entry?

Search this newsgroup for "combobox" and "autocomplete". You should
find pointers to some implementations.

Nov 17 '05 #3
I'm using Google Groups Beta, and searching on "combobox autocomplete"
gets me 18 hits. You'll probably get even more in
microsoft.public.dotnet.framework.windowsforms and
microsoft.public.dotnet.framework.windowsforms.con trols.

Nov 17 '05 #4
I didn't find any.

But perhaps some out there would know how to iterate the list within a
ComboBox. I'm having trouble referencing it.
Nov 17 '05 #5
Here is a post by Jeffrey Tan, from one of the other newsgroups:

I am not sure of your meaning of "searchable combobox", can you show us

more information of your request? If you want to implement a
AutoComplete
combobox, you may refer to the 2 articles below:
"AutoComplete ComboBox in VB.Net"
http://www.codeproject.com/vb/net/au...e_combobox.asp
"ComboBox with AutoComplete 1.1"
http://www.csharphelp.com/archives3/archive502.html
Also, based on my knowledge, in .Net 2.0, Whidbey will introduce a new
AutoComplete feature for the build-in combobox control.
================================================== =====
Thank you for your patience and cooperation. If you have any questions
or
concerns, please feel free to post it in the group. I am standing by to
be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

Nov 17 '05 #6
This looks like what I'm looking for. I will study it and let you know if I
have more questions.

Thanks
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Here is a post by Jeffrey Tan, from one of the other newsgroups:

I am not sure of your meaning of "searchable combobox", can you show us

more information of your request? If you want to implement a
AutoComplete
combobox, you may refer to the 2 articles below:
"AutoComplete ComboBox in VB.Net"
http://www.codeproject.com/vb/net/au...e_combobox.asp
"ComboBox with AutoComplete 1.1"
http://www.csharphelp.com/archives3/archive502.html
Also, based on my knowledge, in .Net 2.0, Whidbey will introduce a new
AutoComplete feature for the build-in combobox control.
================================================== =====
Thank you for your patience and cooperation. If you have any questions
or
concerns, please feel free to post it in the group. I am standing by to
be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

Nov 17 '05 #7
I've just looked over the first example you referred me to and find that it
uses ComboBox.FindString. I didn't know such a thing existed! Don't know
how I missed it.
Thanks.

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Here is a post by Jeffrey Tan, from one of the other newsgroups:

I am not sure of your meaning of "searchable combobox", can you show us

more information of your request? If you want to implement a
AutoComplete
combobox, you may refer to the 2 articles below:
"AutoComplete ComboBox in VB.Net"
http://www.codeproject.com/vb/net/au...e_combobox.asp
"ComboBox with AutoComplete 1.1"
http://www.csharphelp.com/archives3/archive502.html
Also, based on my knowledge, in .Net 2.0, Whidbey will introduce a new
AutoComplete feature for the build-in combobox control.
================================================== =====
Thank you for your patience and cooperation. If you have any questions
or
concerns, please feel free to post it in the group. I am standing by to
be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

Nov 17 '05 #8
Hang on! I spoke to soon. This doesn't answer my problem completely.

I'm still having trouble with the ComboBox internal behavior that causes it
to move to the first item it can find in which the first character matches
the character last typed. The displayed item jumps as the ComboBox moves to
the item that it has selected then on to the one that my code selects. Is
there any way around this?

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Here is a post by Jeffrey Tan, from one of the other newsgroups:

I am not sure of your meaning of "searchable combobox", can you show us

more information of your request? If you want to implement a
AutoComplete
combobox, you may refer to the 2 articles below:
"AutoComplete ComboBox in VB.Net"
http://www.codeproject.com/vb/net/au...e_combobox.asp
"ComboBox with AutoComplete 1.1"
http://www.csharphelp.com/archives3/archive502.html
Also, based on my knowledge, in .Net 2.0, Whidbey will introduce a new
AutoComplete feature for the build-in combobox control.
================================================== =====
Thank you for your patience and cooperation. If you have any questions
or
concerns, please feel free to post it in the group. I am standing by to
be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

Nov 17 '05 #9
I can't seem to visualize your problem... can you explain what's
happening in more detail?

Nov 17 '05 #10
I've tried this with a DropDownStyle set to DropDown and DropDownList.

DropDown works well in that I'm able to use the SelectionStart and
SelectionLength properties to show the user which characters have been
acknowledged. Unfortunately, there is a visible jitter to the search
process. It appears that the component is implementing its default
behavior, which is to find the first item that begins with the character
just entered. It also appears as thought the highlighting of the selected
text is being removed and replaced with each key.

Also, if the user types too fast, characters are skipped in the search
process. I've tried implementing the solution to this expressed on the site
that you referenced in one of your earlier posts
(http://www.codeproject.com/vb/net/au...e_combobox.asp)
but it did not solve the problem.

All of the following processing takes place in KeyUp. I've omitted the code
that handles the backspace and excape keys.

private void cbTaskLookUp_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
string cbText = cbTaskLookUp.Text.ToUpper();
string cbItemText;
int cbTLUL = cbTaskLookUpInput.Length;
ComboBox cb = (ComboBox)sender;
try
{
if ((e.KeyValue < 65 || e.KeyValue > 90) & e.KeyValue != 32)//other keys
are handled elsewhere
return;
cbTaskLookUpInput += (char)e.KeyValue;
lblSoFar.Text = cbTaskLookUpInput;//for debugging
cbTLUL = cbTaskLookUpInput.Length;
LocateCBOItem(cb, cbTaskLookUpInput, cbTLUL);
}

finally
{
e.Handled = true;
}
}

private void LocateCBOItem(ComboBox cb, string InputString, int isLength)
{
int iFindString;
iFindString = cb.FindString(InputString);
cb.SelectedIndex = iFindString;
cb.SelectionStart = 0;
cb.SelectionLength = isLength;
lblSoFar.Text += " " + iFindString.ToString();//for debugging
}

Thanks for your help.


"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I can't seem to visualize your problem... can you explain what's
happening in more detail?

Nov 17 '05 #11
I think I see the problem.

The first link, the vb.net one, inexplicably implements the search
functionality as an event handler that can be attached to any combo
box. While this is nice and general, the event handler code runs _in
addition to_ any other code that would run as a part of a KeyUp event.
In particular, the combo box's normal KeyPress event code runs, then
your KeyUp event handler gets called. That's what is causing the
behaviour you're seeing.

I like the csharphelp version much better (the other link:
http://www.csharphelp.com/archives3/archive502.html ). It implements a
special kind of ComboBox by inheriting from ComboBox and _overriding_
KeyPress. This will have the effect of _replacing_ the normal ComboBox
KeyPress behaviour, which is more likely what you want.

By the way, .NET 2.0, which is due out next month, will include an
autocomplete feature for combo boxes built into the Framework, if you
can wait a month... :)

Nov 17 '05 #12
I checked out the component. This is what I was looking for. It doesn't do
everything I wanted it to do, but I can fix that. I see now how to override
an event handler. I downloaded it and installed the DLL assembly in my
toolbar. I also changed one of the ComboBoxes on my form to the ACComboBox
class. Unfortunately, even though it compiled and ran, after I shut it
down, almost everything on the form that was not inherrited from the
superclass was gone. I was using a TabControl with four pages. The
TabControl is gone and most of the code associated with it is gone.

Do you have any idea what would cause this or how to recover the previous
version of the form?
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I think I see the problem.

The first link, the vb.net one, inexplicably implements the search
functionality as an event handler that can be attached to any combo
box. While this is nice and general, the event handler code runs _in
addition to_ any other code that would run as a part of a KeyUp event.
In particular, the combo box's normal KeyPress event code runs, then
your KeyUp event handler gets called. That's what is causing the
behaviour you're seeing.

I like the csharphelp version much better (the other link:
http://www.csharphelp.com/archives3/archive502.html ). It implements a
special kind of ComboBox by inheriting from ComboBox and _overriding_
KeyPress. This will have the effect of _replacing_ the normal ComboBox
KeyPress behaviour, which is more likely what you want.

By the way, .NET 2.0, which is due out next month, will include an
autocomplete feature for combo boxes built into the Framework, if you
can wait a month... :)

Nov 17 '05 #13
I've had this happen before. It happens when there's "something wrong"
with the code inside the "Windows Form Designer" generated section of
code, which is why they till you never to touch that.

In particular, I get this effect when I make a mistake in the
constructors of one of my derived controls (like the special-purpose
combo box), so the Designer can't create one, or an error in one of the
properties that the Designer is trying to read.

No, there's no way to get the code back, unless you have a version
control system. Debugging custom control is a pain. If you don't have
source code control, keep a back-up copy of your form somewhere.

Nov 17 '05 #14
Alright. Looks like I need hourly backups or a version control system.

Back to the component itself. It needs a little work, especially in the UI;
if the ComboBox isn't wide enough to display all of itscontents, the user
can't see what's happening because it defaults to showing the right side
instead of the left. Also, it doesn't stay in the dropdown mode as the user
is typing in, so even if the dropdown list is wide enough the user is still
lost.

I'm thinking that it may not be worth the trouble to fix it up if there's a
better version coming out in another month. But then on the other hand, I
need addtional functionality -- like 'fetch another batch of records if you
can't find what you're looking for here' -- so I might work with this
version anyway.

Thanks for the tip.
"Bruce Wood" <br*******@canada.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I've had this happen before. It happens when there's "something wrong"
with the code inside the "Windows Form Designer" generated section of
code, which is why they till you never to touch that.

In particular, I get this effect when I make a mistake in the
constructors of one of my derived controls (like the special-purpose
combo box), so the Designer can't create one, or an error in one of the
properties that the Designer is trying to read.

No, there's no way to get the code back, unless you have a version
control system. Debugging custom control is a pain. If you don't have
source code control, keep a back-up copy of your form somewhere.

Nov 17 '05 #15

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

Similar topics

5
by: Anurag | last post by:
Hello, I wish to find out the restore method for database that have been incrementally backed up and in the scenario where just the delta has been backed up. For example sake, let us assume the...
0
by: Colleyville Alan | last post by:
I have an app that looks up an id number and when a button is clicked, inputs the id # into a query. After running the query, I click a second button which grabs the client name rather than the id...
3
by: Colleyville Alan | last post by:
I have a incremental search box that has been working fine for a couple of months but is now acting up. This search box is from the cd that comes with Getz's book, so I did not write it and have...
2
by: mp | last post by:
Hi, Is posible to make incremental search of some databse (table) with c#. I am looking for some example. I know how to do that with Delphi, but I am new in C# .NET and I need your help. ...
1
by: mp | last post by:
Hi, I need help in following... I have used: Visual Studio 2002 or 2003 - C# Access DataBase ADO connection I am looking for example or directions of incremental search.
4
by: rh | last post by:
Hi, I'd like to add an incremental search to my windows form DataGrid that works like the one used in Windows Explorer. In Windows Explorer, when you type a character it jumps to the first item...
4
by: EdB | last post by:
Can anyone provide a sample of how to do an incremental key search on a combo box control?
5
by: Joel Matthew | last post by:
My boss was asking about incremental backups. I was scratching my head, thinking that the transaction log and a backup policy (script) for each record set (sorry about the archaic terminology)...
5
by: DFS | last post by:
This works pretty well, and it's easy, but it's not the ultimate solution. The kludgey part is it uses a hidden field to incrementally capture the keystrokes in the visible field (because executing...
0
by: Bob Greschke | last post by:
I want to create a search function on a Text() widget full of text like the incremental search in emacs -- if you type an "f" emacs goes to the first "f", type another "f" and it goes to the first...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.