Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection as DataSource in ListBox
Message
 
À
28/02/2005 12:17:17
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00990658
Message ID:
00991312
Vues:
13
Bonnie,
Currently this is the code I have in the form's constructor, to add 3 elements to the collection.
try
			{
				this.oIndividualDelayCollection.Add(new ALS.ImageviewConfig.IndividualDelay(1,5));
				this.oIndividualDelayCollection.Add(new ALS.ImageviewConfig.IndividualDelay(2,45));
				this.oIndividualDelayCollection.Add(new ALS.ImageviewConfig.IndividualDelay(42,42));
				this.lstIndividualDelay.DataSource = this.oIndividualDelayCollection;
				this.lstIndividualDelay.SelectedIndex = 0;
				
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.ToString());
			}
This is mostly test code at this point. I will in the future populate the collection by reading through an aspx file.

Here is the code in the listbox' selectedindexchanged:
private void lstIndividualDelay_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.txtIncludeDelay.Text = this.oIndividualDelayCollection[this.lstIndividualDelay.SelectedIndex].IncludeDelay.ToString();
			this.txtIncludeFile.Text = this.oIndividualDelayCollection[this.lstIndividualDelay.SelectedIndex].IncludeFile.ToString();

		}
All this code does is display the contents of the collection element in two textboxes.

Then I added a button, who's click does the following:
this.lstIndividualDelay.DataSource = null;
			this.oIndividualDelayCollection.Add(new ALS.ImageviewConfig.IndividualDelay(1,10));
			
			this.lstIndividualDelay.DataSource = this.oIndividualDelayCollection;
When I run the app and click the button the listbox does not update (no new item added), but when I click where the new item should be the information is displayed in the textboxes. Also if I click one of the elements I can see the textboxes are updated but the blue highlight is not changed.

Any thoughts?

Einar

PS. Thank you very much for taking the time to look at this.



>So, let's see your other code ... the code where you add something to the collection and reset the ListBox DataSource. Also, if you have any code in the ListBox.SelectedIndexChanged() event handler.
>
>~~Bonnie
>
>
>>Bonnie,
>>I still can not get it to "refresh" even when setting the SataSource to null and then setting it back to my collection. I can see through the debugger that the values in the collection has changed. Something even more strange happend once I made the code change, the selected index in the listbox does not appear to change, i.e. the blue hightlighted row does not change, but the selectedindexchanged even fires. Very odd. I am starting to think that I might use a datatable instead <s>, but before I do I would still like to figure this out.
>>Below is the code for the class and for the collection class. Please feel free to comment on both.
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform