public void FillData(List <LicenceInfo> licenceList) { this.listView1.Items.Clear(); if (licenceList != null) { for (int i = 0; i < licenceList.Count; i++) { LicenceInfo licence = licenceList[i]; ListViewItem item = new ListViewItem(); item.SubItems.Add(licence.id.ToString()); item.SubItems.Add(licence.key); item.SubItems.Add(licence.imei); item.SubItems.Add(licence.status.ToString()); item.SubItems.Add(licence.founder); item.SubItems.Add(licence.createTime); item.Tag = licence; this.listView1.Items.Add(item); } this.lblCount.Text = "当前总共" + licenceList.Count + "条记录"; } else { this.lblCount.Text = ""; } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count > 0) { ListViewItem item = this.listView1.SelectedItems[0]; if (item.Tag != null && item.Tag is LicenceInfo) { this.current_Licence = item.Tag as LicenceInfo; if (this.current_Licence.imei == "") { this.btnRegister.Enabled = true; this.btnUpdate.Enabled = false; this.btnLogout.Enabled = false; } else { this.btnRegister.Enabled = false; this.btnUpdate.Enabled = true; this.btnLogout.Enabled = true; } this.btnDelete.Enabled = true; } else { this.current_Licence = null; this.btnUpdate.Enabled = false; this.btnRegister.Enabled = false; this.btnLogout.Enabled = false; this.btnDelete.Enabled = false; } } else { this.current_Licence = null; this.btnUpdate.Enabled = false; this.btnRegister.Enabled = false; this.btnLogout.Enabled = false; this.btnDelete.Enabled = false; } }