Autocomplete textbox with dynamic datasource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
I think you need to add your implementation to IACList and
ICurrentWorkingDirectory as well.
 
Back
Top