private void OnListIndexChanged(object sender, EventArgs e) { this.EditButton.Enabled = false; this.DeleteButton.Enabled = false; var indices = this.List.SelectedIndices; if (indices.Count != 1) { return; } var index = indices[0]; var item = this.List.Items[index]; if PropertyName != null) { this.EditButton.Enabled = PropertyName.CanEdit(item.Text); this.DeleteButton.Enabled = this.CanDelete(item.Text); } }