private void txtSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && this.txtSearch.Text != string.Empty) { if (!this.socketHelper.IsAuthorized) { return; } if (this.pnlAvailableUsers == null) { this.pnlAvailableUsers = new Panel(); this.CreateGroupHeader("AVAILABLE USERS", this.pnlAvailableUsers, lblContactsList.Location, lblSeparator.Location); this.pnlAvailableUsers.Name = "pnlAvailableUsers"; this.pnlAvailableUsers.Location = pnlContactsContainer.Location; this.pnlAvailableUsers.Size = new Size(pnlContactsContainer.Size.Width, pnlContactsContainer.Size.Height - txtSearch.Height); } else { this.ClearAvailableUsersList(); } List <AccountInformation> users = WebConnector.GetAvailableUsers(this.txtSearch.Text, this.accountInfo.Id); foreach (AccountInformation contact in this.contacts.ContactsList) { users.RemoveAll(user => user.Id == contact.Id); } this.pnlDashboard.Controls.Add(pnlAvailableUsers); this.pnlContactsContainer.Hide(); // Add user controls to the available users container this.ListAvailableUsers(users); this.isSearchViewLoaded = true; } }