Click here to Skip to main content
15,916,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form when it loads run a module to get sql server instances. These are in a array. I use this array to load a combo box on the form. User selects the instance and then presses a button. This button does some work and asks if we want to work on next instance.
Now i do not want to display already used instance name in combo box.
But as form will load again, it will run module again all instances in combo box again.
all help/idea is appreciated.
Posted

If you don't want to use LINQ, you will need to loop through the list of arrays and remove previously used servers.
 
Share this answer
 
Comments
Maciej Los 6-Mar-14 14:57pm    
+5!
Abhinav S 6-Mar-14 22:17pm    
Thank you.
So keep a list of the strings you have used, and remove them from the array before you load the combobox.

C#
    string[] servers = GetServers();
    servers = servers.Except(usedServers).ToArray();
    ...

private List<string> usedServers = new List<string>();
 
Share this answer
 
Or you can just check whether the selected Item is already inside the database using a simple select statement, then if it exists, then the item should no longer be in the combobox.
 
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