Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ComboBox.DataSource
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
ComboBox.DataSource
Divers
Thread ID:
01040543
Message ID:
01040543
Vues:
45
I found this a little odd this morning. Considder the code below:
this.oXPortCollection.Add(oXPrt);

// Without the line below the new item added above does not show up in the combobox
this.cboSboxes.DataSource = null;

this.cboSboxes.DataSource = this.oXPortCollection;
At first I did not have the line setting the DataSource to null but without that line the combobox did not display the newly added item to the collection. I added the collection to the watch window and could see that the new item was in there. I also wrote to the console all the items in the collection.

Why do I have to set the DataSource to null first?

I also experimented with code where I created a new collection, added the new item then looped through the old collection and added all the items from the old collection to the new collection. Then I set the old collection to equal the new collection and set the combobox' datasource to the old collection, in that case I did not have to set the datasource to null first.

Any thoughts.

Thanks,
Einar
Semper ubi sub ubi.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform