public void LVTagsItemChecked(object sender, ItemCheckedEventArgs e) { var item = PIBUtils.GetSelectedItem(lvTags); if (item != null && item.Checked) { int used = 0; for (int i = 0; i < lvTags.Items.Count; i++) { if (lvTags.Items[i].Checked) { used++; } } if (used > MAX_TRENDS) { item.Checked = false; } } SelectTags(); }