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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:07+00:00 2026-06-13T20:32:07+00:00

I have two comboboxes. First combobox is for selecting the manager and the second

  • 0

I have two comboboxes. First combobox is for selecting the manager and the second is for selecting Asst. MAnager. But, the source names are same in the both comboxes. Therefore, for example, if I select ” James” from first combobox then I won’t to select it from the second combobox. When I click on “James” in the second combobox, it should give me an error and must not select “JAmes”.

I wrote that code into the second combobox’s selection_changed event:

if (Manager.SelectedItem == Asst_MAnager.SelectedItem)
{
    MessageBox.Show("You must change Asst_Manager");
} 

That is right , if I select same item then it gives me the error message. But, still it selects the same item after error message. My WPF code is below. Could you give me any idea?

<local:ComboBoxCW Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" x:Name="Manager" Text="" Background="#FFC8D2E8"  Margin="0,0,0,3"
            SelectedID="{Binding Path=[Manager}"  />
<local:ComboBoxCW Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" x:Name="Asst_Manager" Text="" Background="#FFC8D2E8" CWListName="Assistant Manager" Margin="0,0,0,3"
            SelectedID="{Binding Path=[Asst_Manager]}" SelectionChanged="Asst_Manager_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-06-13T20:32:08+00:00Added an answer on June 13, 2026 at 8:32 pm

    Since your comboboxes are databound, you can’t set the SelectedIndex to -1 (which should deselect any choices you’ve made, normally), and would look like this:

    if (Manager.SelectedItem == Asst_MAnager.SelectedItem)
    {
        MessageBox.Show("You must change Asst_Manager");
        Asst_Manager.SelectedIndex = -1;
    } 
    

    So, I would suggest in your first item in each box to be “Select a Name”. That way you can do:

    if (Manager.SelectedItem == Asst_MAnager.SelectedItem)
    {
        MessageBox.Show("You must change Asst_Manager");
        Asst_Manager.SelectedIndex = 0;
    } 
    

    Or something similar. It’s not pretty, and by far not the best way. But it’s simple, and gets the job done.

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

Sidebar

Related Questions

I have a form with two ComboBoxes. The second ComboBox holds a list of
I have two seperate WPF Comboboxes both of them bind to the same object
I currently have two comboboxes on a form. The first combobox contains a list
I have got two comboboxes on my application. The first combobox can get all
I have two related ComboBoxes ( continents, and countries ). When the continents ComboBox
I have two dropdowns in html. Both dropdowns are getting data mysql first dropdown
I am using Microsoft Visual Studio 2010 I have two Combobox. -Combobox1.Text -Combobox2.Text first
I have two combobox. I need get some value from first combobox1 after combobox1
I have two ComboBoxes <ComboBox Name=cmbMake DisplayMemberPath=MakeName SelectedValuePath=MakeID/> <ComboBox Name=cmbModel DisplayMemberPath=ModelName/> I use LINQ-to-Entities
So I have two comboBoxes (comboBoxFromAccount and comboBoxToAccount). Each has the same datasource, which

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.