I have been trying to get this to work and can not find why it will not. I have a loading form first which initializes everything then that form closes and the login form shows. The textbox for the username is supposed to get autocomplete values from config file. I can get all the values and it shows in the autocompletecustomsource but when I test it the textbox does not even show suggestions as I type. Here is the code I use to add all the form elements to the form. I have tried putting it in the onload overide as well as the initialization method.
[STAThread]
private void AddControls()
{
Label lb;
TextBox tb;
Button btn;
lb = new Label()
{
AutoSize = true,
Left = 5,
Top = 5,
Text = "Username:",
Font = new Font(this.Font.FontFamily, 7, FontStyle.Italic)
};
this.Controls.Add(lb);
tb = new TextBox()
{
Left = lb.Left,
Top = lb.Bottom + 2,
Width = this.Width - 10,
Name = "user"
};
this.Controls.Add(tb);
AutoCompleteStringCollection ASC = new AutoCompleteStringCollection();
ASC.AddRange(_DataHandler.CFManager.GetConfigValue(BPConfig.CFGVal.Users).Split(';'));
tb.AutoCompleteMode = AutoCompleteMode.Suggest;
tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
tb.AutoCompleteCustomSource = ASC;
}
AutoCompleteStringCollection? Assign the collection to another array before passing it to the collection, so you can better verify what's in it (possibly, trailing spaces and/or empty lines). - Jimi_DataHandler.CFManager.GetConfigValue()is returning is known to you only. If I pass a simple array of strings to theAutoCompleteStringCollectionusing the same code you posted here, it works as expected. - Jimi