Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have Five comboBoxes with same members, when one combobox selects an item, other comboboxes must be unable to select same member.
anyone have solution for this.? help me.

What I have tried:

dont have any idea about this.
Posted
Updated 11-Jul-17 15:39pm
Comments
Joezer BH 10-Jul-17 9:31am    
What do you need?
If you have not tried anyting it meens, first, learn to program in C#...
Andy Lanng 10-Jul-17 9:38am    
5* comment!
Richard Deeming 10-Jul-17 11:55am    
The answer to your question will vary greatly depending on which UI framework you're using.

Is this Windows Forms? WPF? ASP.NET? ASP.NET MVC? ASP.NET Core? Something else?

In Winforms you can use a DataGridView instead of a ComboBox and make the row readonly, see example here: C# DataGridView Read Only Columns and Rows[^]
Here is a way to do it with a standard ComboBox: c# - Disabling particular Items in a Combobox - Stack Overflow[^]
 
Share this answer
 
v2
As you have mentioned ComboBox, I assume you are working on a windows application. Here's the solution.

Create different binding methods to bind data to comboboxes. Then on SelectedIndexChanged event of each combobox you need to remove item(s) you don't want from other comboboxes. To do this you can use RemoveAt() method if you are dealing with List or any similar kind of objects. After removing the items rebind the combobox to bind updated list.
 
Share this answer
 
Assuming that they have the same indexes (because definitely, they do), you can try the following:

1. Create a List or Array that will hold all the selected index every time you select item in the ComboBox and use it to check if the item is already selected from another ComboBox.

Or if you don't want to use List or Array,

2. Use those ComboBoxes itself to check the selected items.

You can just display a Message (ex: MessageBox) or just remove the already selected item/s from other ComboBoxes so that it cannot be selected again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900