Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>ComboBox can autocomplete, but only one word at a time.</p> <p>If you want to have each word separately autocompleted, you have to write your own.</p> <p>I already did, hope it's not too long. It's not 100% exactly what you want, this was used for autocompleting in email client when typing in email adress.</p> <pre><code>/// &lt;summary&gt; /// Extended TextBox with smart auto-completion /// &lt;/summary&gt; public class TextBoxAC: TextBox { private List&lt;string&gt; completions = new List&lt;string&gt;(); private List&lt;string&gt; completionsLow = new List&lt;string&gt;(); private bool autocompleting = false; private bool acDisabled = true; private List&lt;string&gt; possibleCompletions = new List&lt;string&gt;(); private int currentCompletion = 0; /// &lt;summary&gt; /// Default constructor /// &lt;/summary&gt; public TextBoxAC() { this.TextChanged += new EventHandler(TextBoxAC_TextChanged); this.KeyPress += new KeyPressEventHandler(TextBoxAC_KeyPress); this.KeyDown += new KeyEventHandler(TextBoxAC_KeyDown); this.TabStop = true; } /// &lt;summary&gt; /// Sets autocompletion data, list of possible strings /// &lt;/summary&gt; /// &lt;param name="words"&gt;Completion words&lt;/param&gt; /// &lt;param name="wordsLow"&gt;Completion words in lowerCase&lt;/param&gt; public void SetAutoCompletion(List&lt;string&gt; words, List&lt;string&gt; wordsLow) { if (words == null || words.Count &lt; 1) { return; } this.completions = words; this.completionsLow = wordsLow; this.TabStop = false; } private void TextBoxAC_TextChanged(object sender, EventArgs e) { if (this.autocompleting || this.acDisabled) { return; } string text = this.Text; if (text.Length != this.SelectionStart) { return; } int pos = this.SelectionStart; string userPrefix = text.Substring(0, pos); int commaPos = userPrefix.LastIndexOf(","); if (commaPos == -1) { userPrefix = userPrefix.ToLower(); this.possibleCompletions.Clear(); int n = 0; foreach (string s in this.completionsLow) { if (s.StartsWith(userPrefix)) { this.possibleCompletions.Add(this.completions[n]); } n++; } if (this.possibleCompletions.Count &lt; 1) { return; } this.autocompleting = true; this.Text = this.possibleCompletions[0]; this.autocompleting = false; this.SelectionStart = pos; this.SelectionLength = this.Text.Length - pos; } else { string curUs = userPrefix.Substring(commaPos + 1); if (curUs.Trim().Length &lt; 1) { return; } string trimmed; curUs = this.trimOut(curUs, out trimmed); curUs = curUs.ToLower(); string oldUs = userPrefix.Substring(0, commaPos + 1); this.possibleCompletions.Clear(); int n = 0; foreach (string s in this.completionsLow) { if (s.StartsWith(curUs)) { this.possibleCompletions.Add(this.completions[n]); } n++; } if (this.possibleCompletions.Count &lt; 1) { return; } this.autocompleting = true; this.Text = oldUs + trimmed + this.possibleCompletions[0]; this.autocompleting = false; this.SelectionStart = pos; this.SelectionLength = this.Text.Length - pos + trimmed.Length; } this.currentCompletion = 0; } private void TextBoxAC_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) { this.acDisabled = true; } if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) { if ((this.acDisabled) || (this.possibleCompletions.Count &lt; 1)) { return; } e.Handled = true; if (this.possibleCompletions.Count &lt; 2) { return; } switch (e.KeyCode) { case Keys.Up: this.currentCompletion--; if (this.currentCompletion &lt; 0) { this.currentCompletion = this.possibleCompletions.Count - 1; } break; case Keys.Down: this.currentCompletion++; if (this.currentCompletion &gt;= this.possibleCompletions.Count) { this.currentCompletion = 0; } break; } int pos = this.SelectionStart; string userPrefix = this.Text.Substring(0, pos); int commaPos = userPrefix.LastIndexOf(","); if (commaPos == -1) { pos--; userPrefix = this.Text.Substring(0, pos); this.autocompleting = true; this.Text = userPrefix + this.possibleCompletions[this.currentCompletion].Substring(userPrefix.Length); this.autocompleting = false; this.SelectionStart = pos + 1; this.SelectionLength = this.Text.Length - pos; } else { string curUs = userPrefix.Substring(commaPos + 1); if (curUs.Trim().Length &lt; 1) { return; } string trimmed; curUs = this.trimOut(curUs, out trimmed); curUs = curUs.ToLower(); string oldUs = userPrefix.Substring(0, commaPos + 1); this.autocompleting = true; this.Text = oldUs + trimmed + this.possibleCompletions[this.currentCompletion]; this.autocompleting = false; this.SelectionStart = pos; this.SelectionLength = this.Text.Length - pos + trimmed.Length; } } } private void TextBoxAC_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsControl(e.KeyChar)) { this.acDisabled = false; } } private string trimOut(string toTrim, out string trim) { string ret = toTrim.TrimStart(); int pos = toTrim.IndexOf(ret); trim = toTrim.Substring(0, pos); return ret; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload