---
title: "How to get the index of a ComboBox dropdown list in C# on mouse click?"  
description: "How to get the index of a ComboBox dropdown list in C# on mouse click?"  
author: "Revati S Misra"  
published: 2023-09-25  
updated: 2023-09-27  
canonical: https://www.mindstick.com/forum/159906/how-to-get-the-index-of-a-combobox-dropdown-list-in-c-sharp-on-mouse-click  
category: "c#"  
tags: ["c#", "combobox"]  
reading_time: 2 minutes  

---

# How to get the index of a ComboBox dropdown list in C# on mouse click?

How to get the [index](https://www.mindstick.com/blog/198/index-in-sql-server) of a [ComboBox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) [dropdown list](https://www.mindstick.com/forum/760/dropdown-list-open-hide-behind-another-dropdown-list-on-ie-7) in C# on a [mouse](https://yourviews.mindstick.com/story/5122/the-story-behind-lord-ganesha-s-mouse-mushak) [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social)?

## Replies

### Reply by Aryan Kumar

To get the index of a combo box [dropdown](https://www.mindstick.com/articles/263/ajax-toolkit-dropdownextender-in-asp-dot-net) list item in C# when a mouse click event occurs, you can handle the **MouseClick** event of the combo box. Here's how you can do it:

Assuming you have a Windows Forms application with a ComboBox named **comboBox1**, you can add an event handler for the **MouseClick** event like this:

```plaintext
private void comboBox1_MouseClick(object sender, MouseEventArgs e)
{
    // Get the mouse cursor position relative to the combo box
    Point mousePos = comboBox1.PointToClient(Cursor.Position);

    // Get the index of the item that was clicked
    int index = comboBox1.IndexFromPoint(mousePos);

    // Check if an item was clicked
    if (index != -1)
    {
        // Index contains the index of the clicked item
        MessageBox.Show("Clicked item index: " + index);
    }
}
```

Here's what this code does:

1. It registers an event handler for the **MouseClick** event of **comboBox1**.
2. In the event handler, it uses **PointToClient** to get the mouse cursor position relative to the combo box.
3. Then, it uses **IndexFromPoint** to determine the index of the item that was clicked. If no item was clicked, it will return -1.
4. Finally, if an item was clicked (i.e., **index** is not -1), it displays a message box with the index of the clicked item.

Make sure to wire up this event handler in your form's constructor or designer to ensure it gets called when a mouse click occurs on the combo box dropdown list.


---

Original Source: https://www.mindstick.com/forum/159906/how-to-get-the-index-of-a-combobox-dropdown-list-in-c-sharp-on-mouse-click

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
