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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:37:13+00:00 2026-05-30T14:37:13+00:00

I have an event for a ComboBox, SelectionChange. Here’s what I’m trying to do:

  • 0

I have an event for a ComboBox, “SelectionChange”.

Here’s what I’m trying to do:

  1. I have two ComboBoxes
  2. The second ComboBox will display items depending on the selected item on the first Box
  3. ComboBox2 should react as soon as an item on ComboBox1 is selected

My problem is when I’m trying to get the SelectedIndex.

When I use ComboBox1.Text after confirming the SelectedIndex, it returns null so the ComboBox2 doesn’t react.

I tried placing a button to force the event and it did work. It seems that the SelectedIndex doesn’t change until you release focus.

Here’s a snippet of the code:

if (cb_subj.SelectedIndex == ctr)
{
     cb_section.Items.Clear();
     if (connectToDB.openConnection() == true)
     {
         MySqlDataAdapter comboBoxItems_seclist = new MySqlDataAdapter();

         MySqlCommand query = new MySqlCommand(@"SELECT section_code FROM sections 
                             WHERE subject = @subj", connectToDB.connection);
         query.Parameters.AddWithValue("@subj", cb_subj.Text);

         comboBoxItems_seclist.SelectCommand = query;


         System.Data.DataTable classlist = new System.Data.DataTable();

         comboBoxItems_seclist.Fill(classlist);

         foreach (System.Data.DataRow row in classlist.Rows)
         {
            string rows = string.Format("{0}", row.ItemArray[0]);
            cb_section.Items.Add(rows);
         }
       }

      break;
}

Here’s the XAML of the two CB:

<ComboBox Height="23" HorizontalAlignment="Left" Margin="166,12,0,0" Name="cbox_year" VerticalAlignment="Top" Width="120" SelectionChanged="cbox_year_SelectionChanged">
        <ComboBoxItem Content="1st Year / 1st Sem" />
        <ComboBoxItem Content="1st Year / 2nd Sem" />
        <ComboBoxItem Content="2nd Year / 1st Sem" />
        <ComboBoxItem Content="2nd Year / 2nd Sem" />
        <ComboBoxItem Content="3rd Year / 1st Sem" />
        <ComboBoxItem Content="3rd Year / 2nd Sem" />
        <ComboBoxItem Content="4th Year / 1st Sem" />
        <ComboBoxItem Content="4th Year / 2nd Sem" />
    </ComboBox>
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="166,41,0,0" Name="cb_subj" VerticalAlignment="Top" Width="120" SelectionChanged="cb_subj_SelectionChanged" />
  • 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-30T14:37:15+00:00Added an answer on May 30, 2026 at 2:37 pm

    For a quick success, you could access ComboBox1.SelectedValue or ComboBox1.SelectedItem instead of ComboBox1.Text.

    Your main problem seems to be that when selection changes in ComboBox1, it does not directly change the ComboBox1.Text, you (i.e. the focus) will have to leave ComboBox1 until the Text is updated. Typically, you can avoid such problems by using databinding instead of this eventbased approach.

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

Sidebar

Related Questions

I have two comboboxes. First combobox is for selecting the manager and the second
I have 2 questions on kendo combobox change event. On change event I want
I have a System.Windows.Forms.ComboBox on a form and I want to capture the event
I have two event handlers wired up to a button click in a Windows
If I have a ComboBox that has a SelectionChanged event, it fires when I'm
I have two ComboBoxes, A & B, each bound to an Observable Collection. Each
I have a combobox in silverlight mvvm. i need to wrote the event for
I have a simple comboBox with some Value/Text items in it. I have using
I have a datagridcombobox column, how do I raise an event for combobox item
I have created two comboboxes. I have to create a match the following program,

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.