Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2007

Tip: Looking for answers? Try searching our database.

Autocomplete textbox with dynamic datasource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andy gilman - 24 Sep 2007 21:04 GMT
I know how to use autocomplete with 2.0 framework on a textbox. I also know
how to use COM interop to use the IAutoComplete interface directly.

But with either approach I seem unable to change the list while the user is
typing.
I have an XML document and i want the user to be able to navigate to nodes
by typing in an XPath.

i.e. when the user types /A
it pops up with
/Animals
/Applications

and when they type
/Animals/
it pops up with:
/Animals/Dog
/Animals/Cat

I do NOT want to prepopulate the whole list.

However when using the .NET framework and changing the list I get an 'Access
Violation' exception which is unacceptable.

I tried to use the AutoComplete COM control (IAutoComplete) based upon this
blog entry :
http://jiangsheng.spaces.live.com/blog/cns!1BE894DEAF296E0A!732.entry

Unfortunately the control doesn't 'ask' for an updated list of items as I
type. I've tried all kinds of nasty tricks, like faking an 'Escape' key press
but none are acceptable because of unwanted sideeffects.

I essentially want the same behavior you get with the windows filename
autocompletion, but I dont see how I can achieve this. I might just have to
make my own autocomplete dropdown,but woudl rather not have to do that.

Any suggestions?

-andy
Sheng Jiang[MVP] - 26 Sep 2007 19:43 GMT
article updated, basically I cleared the text and type it again
programmatically
if(textBoxDemo->SelectionStart>0)
           {
               autocompleteBindingSource1->Reset();
               autocompleteBindingSource1->Bind();
               String^ text=textBoxDemo->Text;
               int selectionStart=textBoxDemo->SelectionStart;
               int selectionLength=textBoxDemo->SelectionLength;
               textBoxDemo->SelectionStart=0;
               textBoxDemo->SelectionLength=0;
               textBoxDemo->SelectAll();
               System::Windows::Forms::SendKeys::SendWait("{BACKSPACE}");
               textBoxDemo->Text=text;
               textBoxDemo->SelectionStart=selectionStart-1;
               textBoxDemo->SelectionLength=selectionLength+1;

System::Windows::Forms::SendKeys::SendWait(textBoxDemo->SelectedText);
           }
only work in autosuggest mode though.

Signature

Sheng Jiang
Microsoft MVP in VC++

> I know how to use autocomplete with 2.0 framework on a textbox. I also know
> how to use COM interop to use the IAutoComplete interface directly.
[quoted text clipped - 35 lines]
>
> -andy
Sheng Jiang[MVP] - 26 Sep 2007 20:22 GMT
I think you need to add your implementation to IACList and
ICurrentWorkingDirectory as well.

Signature

Sheng Jiang
Microsoft MVP in VC++

> I know how to use autocomplete with 2.0 framework on a textbox. I also know
> how to use COM interop to use the IAutoComplete interface directly.
[quoted text clipped - 35 lines]
>
> -andy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.