Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ListBox problems
Message
De
02/03/2005 15:36:11
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00992047
Message ID:
00992140
Vues:
15
Chad,

Well, whaddaya know? It actually works! Very strange ... I don't know why setting the .SelectedIndex to 0 prior to setting the DataSource to null would make the difference, but it does. The weird thing is that as soon as you set the DataSource to null, the .SelectedIndex goes to -1 (which I would expect) ... so how the heck does setting it to 0 before it goes to -1 make it work?

Very, very peculiar!!

~~Bonnie


>Einar,
>
>I would actually expect an error by setting the Selected index after setting the datasource to null. I just tested this and it works for me:
>
>
>int index = this.listBox1.SelectedIndex;
>this.listBox1.SelectedIndex = 0;
>this.listBox1.DataSource = null;
>this.oCol.RemoveAt(index);
>this.listBox1.DataSource = this.oCol;
>this.listBox1.Refresh();
>
>
>I doubt the Refresh() is necessary. And you could also build in some logic to reposition the selected index close to where it was.
>
>HTH,
>Chad
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform