public void ShowInregionPerson(List <InRegionPerson> person) { int pCount = person != null ? person.Count : 0; int ucdCount = _Controls != null ? _Controls.Count : 0; for (int i = pCount; i < ucdCount; i++) //多余的控件删除掉 { this.Controls.RemoveAt(pCount); _Controls.RemoveAt(pCount); } for (int i = ucdCount; i < pCount; i++) { UCUser ucd = new UCUser(); ucd.Visible = false; ucd.DoubleClick += new EventHandler(ucd_DoubleClick); _Controls.Add(ucd); } if (person != null && person.Count > 0) { for (int i = 0; i < person.Count; i++) { UCUser ucd = _Controls[i]; ucd.Tag = person[i]; ucd.Title = person[i].UserName; ucd.BackColor = person[i].IsTimeout ? Color.Red : Color.Blue; ucd.ForeColor = Color.White; } PerformLayoutItems(_Controls); } }
private void ShowUser(int row, int col, UCUser ucd) { if (!this.Controls.Contains(ucd)) { this.Controls.Add(ucd); } Point p = new Point(ITEMWIDTH * col + ColSpliter * (col + 1), ITEMHEIGHT * row + ColSpliter * (row + 1)); ucd.Visible = true; ucd.BorderStyle = BorderStyle.FixedSingle; ucd.Location = p; ucd.Width = ITEMWIDTH; ucd.Height = ITEMHEIGHT; }