private void CommentTextfield_GotFocus(object sender, EventArgs e) { string projectName = ""; if (sender == currentComment && currentProject != null) { projectName = currentProject.Text; } else { var commentIndex = comments.IndexOf((TextBox)sender); if (commentIndex != -1) { projectName = projects[commentIndex].Text; } } var suggestions = Handler.getSuggestedComments(projectName); var suggestionList = new AutoCompleteStringCollection(); suggestionList.AddRange(suggestions.ToArray()); ((TextBox)sender).AutoCompleteCustomSource = suggestionList; }