Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:00:56+00:00 2026-06-13T07:00:56+00:00

I am adding ComboBoxes dynamically at runtime as shown below. The problem that I

  • 0

I am adding ComboBoxes dynamically at runtime as shown below.
The problem that I am having is that i do not know which of the comboboxes the user is using.

For eg. The user decides to add 5 comboBoxes to the form, and then goes to the first comboBox,and selects a value, I need to retrieve the value of that comboBox.

What the below code is doing – My approach

I am adding a comboBox to a FlowlayoutPanel and the retrieve its name based on the mouse co-ordinates…. this by the way is not working… and I have no idea what to do.

Any help is greatly appreciated.

public partial class Form1 : Form
{
    int count = 0;

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        count += 1;

        ComboBox cb = new ComboBox();
        cb.Name = count.ToString();
        cb.MouseHover += new EventHandler(doStuff);

        Label lb = new Label();
        lb.Text = count.ToString();

        flowLayoutPanel1.Controls.Add(cb);
        flowLayoutPanel1.Controls.Add(lb);
    }

    public void doStuff(object sender, EventArgs e)
    {
        label1.Text = flowLayoutPanel1.GetChildAtPoint(Cursor.Position).Name;
    }
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:00:57+00:00Added an answer on June 13, 2026 at 7:00 am

    You could try:

    cb.SelectionChangeCommitted += selectionChangedHandler
    
    ...
    
    void selectionChangedHandler(object sender, EventArgs e) {
      ComboBox cb = (ComboBox)sender;
      label1.Text = cb.Name;
      // Do whatever else is needed with the combo box
    }
    

    The SelectionChangeCommitted event is “raised only when the user changes the combo box selection“, which sounds like what you’re after.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding items to a ComboBox at runtime. Everything works fine but the problem
When adding items to a ComboBox I know that I could simply define some
I'm using ExtJs4 and I'm trying to extend the Ext.form.field.ComboBox like below: Ext.define('GenericCombo', {
Using the ultra-simple code below, as soon as I press a key on my
I'm creating a WPF application using the MVVM design pattern that consists of a
I am working in C# windows forms application in which I am adding 3
I am working on a Windows Form that has multiple comboboxes. Depending on what
I am adding objects from classes which are derived from UserControl to a ComboBox
I have a combobox that I don't want users adding new data too, but
I have 2 comboboxes like on the image and would like to know if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.