Hi,
I am using UltraCombo with AutoCompleteMode.Suggest and I want to auto populate it with data that will come from database
when user types 2 characters.
The issue I am experiencing is that Auto Suggest List is not displayed when I set DataSource after 2nd character but rather on the 3rd character.
Is there a way I can force AutoSuggest drop down list once I set DataSource?
ultraCombo.KeyUp += (sender, args) => { var combo = sender as UltraCombo; var value = combo.Text ?? "";
if (value.Length == 2) { combo.DataSource = new List<string>{ "A", "AA11", "AA21", "AA31" }; }
// Force elements from DataSource to get displayed o }; }
When I type AA I would like to populate list and get it dysplayed, AytoComplete will be filtering list for other characters length (3,4,5....)
I did manage to use combo.ToggleDropdown();
But the issue with this one is that text gets selected so the next character user types deletes the previous entry.
"aa" - I populate datasource and display list, test get selected
user types "1"
Instead of aa1 it gets 1 as previous text aa was selected when toggle is called!
Hi Milan,
If I am following correctly the snippet below should do what you are looking for. Specifically the part that you are likely missing is just to set the combo.TextBox.SelectionStart = combo.Text.Length.
private void Form1_Load(object sender, EventArgs e) { this.ultraCombo1.AutoCompleteMode = igWin.AutoCompleteMode.Suggest; this.ultraCombo1.TextChanged += UltraCombo1_TextChanged; }
private void UltraCombo1_TextChanged(object sender, EventArgs e) { var combo = sender as UltraCombo;
if (combo == null) return;
if (combo.DataSource == null && combo.Text.Length >= 2 && combo.IsDroppedDown == false) { combo.DataSource = GetDataSource(combo.Text); combo.ToggleDropdown(); combo.Textbox.SelectionStart = combo.Text.Length; }
}
private IEnumerable GetDataSource(string seed) { List<string> retVal = new List<string>();
if (seed != null && seed.Length >= 2) { string prefix = seed.Substring(0, 2);
for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { retVal.Add(string.Format("{0}{1}{2}", prefix, i, j)); } } }
return retVal; }
Let me know if this answers your question,