/// <summary> /// 初始化内容 /// </summary> public void initListContent() { for (int i = 0; i < unit; i++) { MListItem2 item = new MListItem2(i.ToString()); item.ItemIndex = i; item.Location = new Point(i % 3 * item.Width + 10, item.Height * (i / 3)); //this.Controls.Add(item); mBtn += item.buttonMove; } }
private void removeItem() { if (this.Controls.Count > 0) { for (int i = 0; i < this.Controls.Count; i++) { if (!(this.Controls[i] is MListItem2)) { continue; } MListItem2 item = this.Controls[i] as MListItem2; item.onMItemClick -= onMItemClick; mBtn -= item.buttonMove; this.Controls.Remove(item); item.Dispose(); } } }
/// <summary> /// 加载新数据 /// </summary> /// <param name="lastPosition">最后一条记录的位置</param> public void loadNewData(List <QuYuBean> fileQuYuBeans) { List <QuYuBean> QuYuBeans = fileQuYuBeans.ToList(); if (QuYuBeans == null) { return; } int count = QuYuBeans.Count; if (count < 0) { return; } this.Controls.Clear(); //removeItem(); max = count; for (int i = 0; i < count; i++) { MListItem2 item = new MListItem2(QuYuBeans[i]); item.Begin_color = colors[i % 9][0]; item.End_color = colors[i % 9][1]; item.onMItemClick += onMItemClick; item.ItemIndex = i; item.setLabColor(); item.Location = new Point(i % 3 * item.Width + 10, item.Height * (i / 3)); try { this.Controls.Add(item); } catch { continue; } mBtn += item.buttonMove; } }
//int count = 0; public void changePeopleCount(List <QuYuBean> QuYuBeans) { if (QuYuBeans == null || QuYuBeans.Count == 0) { return; } foreach (Control col in this.Controls) { if (!(col is MListItem2)) { continue; } MListItem2 item2 = (MListItem2)col; foreach (QuYuBean qy in QuYuBeans) { if (item2.QuYuBean.QuyuID.Equals(qy.QuyuID)) { item2.setPeopleCount(qy.PepleCount);//count); } } } //count++; //if (count > 1200) count = 1; }