---
title: "Checkbox Selected Index is selected"  
description: "Checkbox Selected Index is selected"  
author: "Anonymous User"  
published: 2014-01-29  
updated: 2014-01-29  
canonical: https://www.mindstick.com/forum/1914/checkbox-selected-index-is-selected  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Checkbox Selected Index is selected

I have a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) [IF statement](https://www.mindstick.com/forum/12682/jquery-toggle-if-statement) in my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) that i want to prompt the [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) if the [item](https://www.mindstick.com/forum/156564/remove-item-in-an-array-in-javascript) in [index](https://www.mindstick.com/blog/198/index-in-sql-server) 2 of my checkedlistbox1 is selected.

It works when index 2 by itself is selected BUT does not work when other [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) including index 2 are checked in my checklist box. Below is what i have that works, now i just need it to work when 2 and [others](https://answers.mindstick.com/qa/33516/what-is-dependency-injection-do-you-use-any-di-library-in-your-project-can-you-name-a-few-of-them-and-why-one-is-better-than-others) are selected.

if (checkedListBox1.SelectedIndex == 2)

{

MessageBox.Show("Note to [send email](https://www.mindstick.com/interview/2006/how-can-you-send-an-email-message-from-an-asp-dot-net-web-page)", "Note", MessageBoxButtons.OK);

}

## Replies

### Reply by Pravesh Singh

Hi John,\

Replace that code with

```
if (checkedListBox1.SelectedIndices.Contains(2)){  
MessageBox.Show("Note to send email", "Note",
MessageBoxButtons.OK);}
```

That will check if 2 is among all selected items.


---

Original Source: https://www.mindstick.com/forum/1914/checkbox-selected-index-is-selected

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
