By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

TextBox AutoComplete not quite good enough

P: n/a
I want to have AutoSuggest based on a database (or webservice) query. So as
the user types say... a last name I will make an async call to a service to
get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock the
control up from any additional text input and the autocomplete list is not
displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond the
built is sources?
Jan 13 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
OK, I got this figured out. It's pretty cool actually and works better than
I thought. It's screaming to be extended to clean up the behavior, I will
post the extended control later when I'm done.

-Steve

"Steve K." <no***@nowhere.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
>I want to have AutoSuggest based on a database (or webservice) query. So
as the user types say... a last name I will make an async call to a service
to get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock
the control up from any additional text input and the autocomplete list is
not displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond the
built is sources?

Jan 13 '08 #2

P: n/a
Well, this is a bit anticlimactic.
There are a TON of bugs when you specify OwnerDraw for a TextBox... it's
useless.

So... if and when I find a workaround I will post the code.
-Steve

"Steve K." <no***@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
OK, I got this figured out. It's pretty cool actually and works better
than I thought. It's screaming to be extended to clean up the behavior, I
will post the extended control later when I'm done.

-Steve

"Steve K." <no***@nowhere.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
>>I want to have AutoSuggest based on a database (or webservice) query. So
as the user types say... a last name I will make an async call to a
service to get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock
the control up from any additional text input and the autocomplete list
is not displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond the
built is sources?


Jan 14 '08 #3

P: n/a
Hi,

Are you using asp.net ?
In a win app you would have to use another cntrol to hold the list of items.
I know that the framework does not provide anything like thta, you should
first try to google for a similar control or check a third party control set
(like infragistics) to see if they provide it.

"Steve K." <no***@nowhere.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
>I want to have AutoSuggest based on a database (or webservice) query. So
as the user types say... a last name I will make an async call to a service
to get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock
the control up from any additional text input and the autocomplete list is
not displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond the
built is sources?
Jan 14 '08 #4

P: n/a
Hi,

Thanks for the reply.
I've got it working pretty well. I'm only displaying strings for the
suggestions, but their values are pulled from a database.

I've derived my own TextBox class that adds some events and properties to
make it a little easier (IMHO).
For example:

// This is an event handler in the host form:
private void pmdTextBox1_AutoCompleteListNeeded(object sender,
AutoCompleteListNeededEventArgs args)
{
string[] dummy = new string[] { "Apple", "Appalachian", "Appp",
"Appppppp" };
args.SourceList = dummy;
}

I will post the code later. It's become quite large as it's next to
impossible to do User Painting with a TextBox although there are ways... it
has made the code grow.

More info later,
Steve
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:Od**************@TK2MSFTNGP05.phx.gbl...
Hi,

Are you using asp.net ?
In a win app you would have to use another cntrol to hold the list of
items. I know that the framework does not provide anything like thta, you
should first try to google for a similar control or check a third party
control set (like infragistics) to see if they provide it.

"Steve K." <no***@nowhere.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
>>I want to have AutoSuggest based on a database (or webservice) query. So
as the user types say... a last name I will make an async call to a
service to get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock
the control up from any additional text input and the autocomplete list
is not displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond the
built is sources?

Jan 14 '08 #5

P: n/a
If anyone is interested I have posted the code here:
http://pmddirect.com/sklett/PMDTextBoxReview.html

This is the first project I've done like this so if you find it at all
interesting or just like to comment I would REALLY like to know what I'm
doing right and what I'm doing wrong and any possible suggestions you might
have.

-Steve

"Steve K." <no***@nowhere.comwrote in message
news:ek**************@TK2MSFTNGP05.phx.gbl...
Hi,

Thanks for the reply.
I've got it working pretty well. I'm only displaying strings for the
suggestions, but their values are pulled from a database.

I've derived my own TextBox class that adds some events and properties to
make it a little easier (IMHO).
For example:

// This is an event handler in the host form:
private void pmdTextBox1_AutoCompleteListNeeded(object sender,
AutoCompleteListNeededEventArgs args)
{
string[] dummy = new string[] { "Apple", "Appalachian", "Appp",
"Appppppp" };
args.SourceList = dummy;
}

I will post the code later. It's become quite large as it's next to
impossible to do User Painting with a TextBox although there are ways...
it has made the code grow.

More info later,
Steve
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:Od**************@TK2MSFTNGP05.phx.gbl...
>Hi,

Are you using asp.net ?
In a win app you would have to use another cntrol to hold the list of
items. I know that the framework does not provide anything like thta, you
should first try to google for a similar control or check a third party
control set (like infragistics) to see if they provide it.

"Steve K." <no***@nowhere.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
>>>I want to have AutoSuggest based on a database (or webservice) query. So
as the user types say... a last name I will make an async call to a
service to get matches, then set the suggestion list at runtime.

I tried this quick by handling the key down event and building a "dumb"
Suggestion list and assigning to the TextBox control but it seem to lock
the control up from any additional text input and the autocomplete list
is not displayed.

Has anyone mananaged to put this feature of the TextBox to use beyond
the built is sources?


Jan 14 '08 #6

P: n/a
This is the first project I've done like this so if you find it at all
interesting or just like to comment I would REALLY like to know what I'm
doing right and what I'm doing wrong and any possible suggestions you
might have.
Can you use ComBox for this ?
Can you make it running in MONO (remove direct winapi calls ) ?

Combobox native dropdown button can be used to open search window like in
IE.
Also, .NET 2 Combobox custom AutoCompleteSource can be used to remove custom
paining.

Andrus.
Jan 14 '08 #7

P: n/a

"Andrus" <ko********@hot.eewrote in message
news:OV**************@TK2MSFTNGP04.phx.gbl...
>This is the first project I've done like this so if you find it at all
interesting or just like to comment I would REALLY like to know what I'm
doing right and what I'm doing wrong and any possible suggestions you
might have.

Can you use ComBox for this ?
In the case there is no match I still want the user to type in the intended
value. I'm not sure how the combobox would work in this regard.
Can you make it running in MONO (remove direct winapi calls ) ?
No, maybe someone could, but I can't. I've never even seen linux ;0)
>
Combobox native dropdown button can be used to open search window like in
IE.
Also, .NET 2 Combobox custom AutoCompleteSource can be used to remove
custom paining.
I'm not painting the list of items, I'm letting the TextBox do that. I'm
paiting the small icon and the "Add New" link.
>
Andrus.

Jan 14 '08 #8

P: n/a
>Can you use ComBox for this ?
>
In the case there is no match I still want the user to type in the
intended value. I'm not sure how the combobox would work in this regard.
comboBox contians textbox so all textbox goodis must apply.
Combobox Dropdown style allows to enter free text into int.
>Can you make it running in MONO (remove direct winapi calls ) ?
No, maybe someone could, but I can't. I've never even seen linux ;0)
You can download and run MONO in Windows.
>Combobox native dropdown button can be used to open search window like in
IE.
Also, .NET 2 Combobox custom AutoCompleteSource can be used to remove
custom paining.

I'm not painting the list of items, I'm letting the TextBox do that. I'm
paiting the small icon and the "Add New" link.
Can you remove direct windows api calls by using combobox dropdown button ?

Andrus.
Jan 14 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.