Groups | Blog | Home
all groups > dotnet windows forms > january 2005 >

dotnet windows forms : Text Auto-completion


Samir
1/7/2005 4:47:01 AM
Hi All,

I am developing an xml editor, inwhich I want to include text
auto-completion.
When I finish entering start element (ie.<Hello>) on rich text box,
the end element (ie.</Hello>) should be entered automatically and also
the cursor is automatically positioned in between the start element
and end element(ie.<Hello>|</Hello>). How should I do this using C#
for Windows environment?

Thanx in advance.
Bob Powell [MVP]
1/7/2005 6:40:46 PM
Having done this in the past I'll tell you how...

You need a decent BTree collection implementation which can be a bought in
third-party or home-grown one. To be honest writing one yourself is a pain,
I bought BTree Gold.

Then, as you type, trap the textbox change event and feed the first n
characters into the btree. It will give you back an array of all words that
begin with that character sequence.

I did a medical dictionary lookup for a company that needed to search
100,000+ words and phrases. the search was as fast as I could type so it was
a great result.

HTH

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





[quoted text, click to view]

AddThis Social Bookmark Button