I'm working on texteditor and I'd like to know how to implement an autocomplete feature.
I have this collection of strings in my separate class (KeyWord.cs)
public String[] keywords = { "abstract", "as", "etc." };
public String[] events = { "AcceptRejectRule", "AccessibleEvents", "etc.2" };
that I already have input the Strings in ListBox (lb) located my mainform, which are already sorted:
lb = new ListBox();
Controls.Add(lb);
//lb.Visible = false;
KeyWord keywordsL = new KeyWord();
KeyWord eventsL = new KeyWord();
foreach (string str in keywordsL.keywords)
{
lb.Items.Add(str);
}
foreach (string str in eventsL.events)
{
lb.Items.Add(str);
}
and the RichTextBox which served as the editor (with highlights option also) declared as rtb.
Now my concern was, how can I make it like its "contexthint" like when I type in letter "A" in RichTextBox(rtb), a hidden listbox will appear in the position where the mousepointer was there and then all the "A" in the beggining of strings listed in the listbox will appear. Finally, when I select the shown string from listbox, the string will be added in the in the RichTextBox?