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 6552153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:25:32+00:00 2026-05-25T12:25:32+00:00

I have a combobox named cmbSubjects . It’s purpose in my project is to

  • 0

I have a combobox named cmbSubjects. It’s purpose in my project is to change the subject in a quiz competition. I want it that when its selected item is changed, a message box should ask the quiz master to confirm if they will like to continue if there are unanswered questions on the subject in the combobox before the change. If they answer NO, the combobox should select its previously selected item. I got this code to do it but the problem is the messagebox appears twice if the quix master chooses NO on the messagebox. I found out the reason (after stepping into the code from a breakpoint) was that when the messagebox returns NO, my code changes the selected value of the combobox to its previous value, which triggers the cmbSubjects_SelectedIndexChanged event. I tried modifying the code by adding a variable to count the number of times the messagebox has appeared to prevent it. The problem is that it only appears after the combobox’s value is first changed. The code below is actually the modified one. Can anyone help me with this? Thanks in advance. (I’m using C#)

private void cmbSubjects_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (pnlAvailable.Controls.Count != 0)
        {
            if (countMsg < 1)
            {
                DialogResult res = MessageBox.Show("There are still available questions. Are you sure you want to change the subject?", "Changing subject...", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                if (res == DialogResult.Yes)
                {
                    cmbIndex = cmbSubjects.SelectedIndex;
                    countMsg = 0;
                    switch (cmbSubjects.SelectedIndex)
                    {
                        case 0:
                            subject = "life";
                            break;
                        case 1:
                            subject = "math";
                            break;
                        case 2:
                            subject = "physical";
                            break;
                        case 3:
                            subject = "technology";
                            break;
                        case 4:
                            subject = "vocational";
                            break;
                    }

                    GenQstBtns();
                }
                else if (res == DialogResult.No)
                {
                    countMsg = 1;
                    cmbSubjects.SelectedIndex = cmbIndex;
                }
            }
        }
    }
  • 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-05-25T12:25:33+00:00Added an answer on May 25, 2026 at 12:25 pm

    You can use SelectionChangeCommitted event.

    Do not use SelectedIndexChanged or SelectedValueChanged to capture user changes, because those events are also raised when the selection changes programmatically.

    So if you use this event after you change selected item programmatically this event wont be fired again

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

Sidebar

Related Questions

I have a WPF ComboBox named cbFileSize. I try to get is selected value
I have a comboBox that has a datatrigger that set its SelectedIndex based on
I have a named comboBox, let's call it: comboBox1 I want to reference the
I have a two columns named Company & Project I want to select all
I have a JComboBox named jComboBox18 and a JTextArea jTextArea11. Now I want that
I have a combobox that has the entries of a full name, eg: John
At the moment I have a combobox that is populated from the name fields
I have a combobox whose value I want to use with a SQL WHERE
I have a combobox that is binding to an ObservableCollection of strings in an
I have two combobox in my Access form named CombDate and CombDat1. Now I

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.