TextBox AutoComplete not quite good enough

S

Steve K.

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?
 
S

Steve K.

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
 
S

Steve K.

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 
S

Steve K.

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
 
S

Steve K.

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. said:
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 ) said:
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.
 
A

Andrus

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.
 
S

Steve K.

Andrus said:
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.
 
A

Andrus

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.
No, maybe someone could, but I can't. I've never even seen linux ;0)

You can download and run MONO in Windows.
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top