Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to bind the object in listbox?

IList availableList = null;
        availableList = EngineServiceProvider.GetInstance().GetAvailableInstances();
        if (availableList != null)
        {
            ConfigurationInstance configInstance = OperatorConfigSettings.GetInstance().GetConfiguredInstance();
            ArrayList configList = configInstance.ConfiguredEngines;
            foreach (EngineInstanceStatus instance in availableList)
            {
                if (configList != null)
                {
                    bool selected = false;
                    foreach (int instanceId in configList)
                    {
                        if (instance.InstanceId == instanceId)
                        {
                            toListBox.Items.Add(instance.ToString());
                            selected = true;
                            break;
                        }
                    }
                   
                    if (!selected)
                    {
                        fromListBox.Items.Add(instance);
//this one is not excuted 
                    }
                }
                else
                {
                    fromListBox.Items.Add(instance);
                }
Posted
Updated 7-Oct-10 21:06pm
v2
Comments
Hiren solanki 8-Oct-10 3:06am    
updated pre tags for better code visibility.

1 solution

XML
Try this code:<br />
<code>
<pre>
    IList availableList = null;
        availableList = EngineServiceProvider.GetInstance().GetAvailableInstances();
        if (availableList != null)
        {
            ConfigurationInstance configInstance = OperatorConfigSettings.GetInstance().GetConfiguredInstance();
            ArrayList configList = configInstance.ConfiguredEngines;
            foreach (EngineInstanceStatus instance in availableList)
            {
                if (configList != null)
                {
            if(configList.Contains(instance.InstanceId))
                 toListBox.Items.Add(instance.ToString());
            else
                 fromListBox.Items.Add(instance);
                }
                else
                {
                    fromListBox.Items.Add(instance);
                }
    }
</pre>
</co

de
 
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