/* Load the users logged from arraylist to a listbox and make it reload */ public void loggedBoxLoad(ListBox lb, TextBox tbx, string slt) { if (lb.InvokeRequired) { LoggedBoxCallback fbc = new LoggedBoxCallback(loggedBoxLoad); Invoke(fbc, new object[] { lb, tbx, slt }); } else { lb.Items.Clear(); mainList = new ArrayList(); mainList = formMain.mainList; string filter = tbx.Text; // Bind the userList from the main form mainList = formMain.mainList; // Loads the userList to a listbox foreach (User user in mainList) { // Verifies if the computer matches empty filter if (filter.Trim().Equals("")) { bool filtered = false; // Verifies each of the filters applied for (int t = 0; t < monitors.Length; t++) { string auxFilter = monitors[t].tbx.Text; if (user.Computer.IndexOf(auxFilter, StringComparison.OrdinalIgnoreCase) == 0 && !auxFilter.Equals("")) { filtered = true; } } if (!filtered) { lb.Items.Add(user.Computer + " \\ " + user.Name); } } // Verifies if the computer matches some filter else if (user.Computer.IndexOf(filter, StringComparison.OrdinalIgnoreCase) == 0 && !filter.Equals("")) { lb.Items.Add(user.Computer + " \\ " + user.Name); } } lb.Refresh(); //lb.Update(); if (lb.FindStringExact(slt) >= 0) { slt = lb.SelectedItem.ToString(); lb.SelectedIndex = lb.FindStringExact(slt); } } }
/* Load the users logged from arraylist to a listbox and make it reload */ public async void loggedBoxLoad(ListBox lb) { Application.DoEvents(); //ThreadSafe(() => //{ if (lb.InvokeRequired) { LoggedBoxCallback fbc = new LoggedBoxCallback(loggedBoxLoad); Invoke(fbc, new object[] { lb }); } else { //SuspendLayout(); userList = new ArrayList(); userList = await getLogged(); mainList = userList; lb.Items.Clear(); // Loads the userList to a listbox foreach (User user in userList) { lb.Items.Add(user.Computer + " \\ " + user.Name); } lb.Refresh(); // lb.Update(); Application.DoEvents(); if (lb.FindStringExact(selectedLogged) >= 0) { lb.SelectedIndex = lb.FindStringExact(selectedLogged); } //ResumeLayout(); } //}); }