Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ListView control problem
Message
De
03/08/2005 14:16:29
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01038228
Message ID:
01038236
Vues:
19
This should work Einar ... I do it all the time, no Refresh necessary. Where are you executing this code? In an event handler or what? (not that it matters, but I'm just trying to figure out why it's not working)

~~Bonnie



>I have a listview that I have filled with items and sub items. Then I want to change the test of a subitem and I use the following code:
>
>this.listView1.Items[0].SubItems[1].Text = "Hi there";
>
>
>Then I issue the following code to see if it changed:
>
>MessageBox.Show(this.listView1.Items[0].SubItems[1].Text);
>
>
>The messagebox displays "Hi There" and I think all is good, but all is not good, because the listview is still displaying the original value. I tried adding this.listView1.Refresh(); after the code where I change the text but that does not help.
>
>Any thoughts on the subject?
>
>Einar
>
>UPDATE:
>I figured out a way that works, but it seems like a lot of work for such a trivial task:
>
>ListViewItem lvi;
>ListViewItem.ListViewSubItem lvsi;
>
>this.listView1.BeginUpdate();
>
>lvi = new ListViewItem();
>lvi.Text = this.listView1.Items[0].Text;
>
>lvsi = new ListViewItem.ListViewSubItem();
>lvsi.Text = "Hi There";
>
>lvi.SubItems.Add(lvsi);
>this.listView1.Items[0] = lvi;
>this.listView1.EndUpdate();
>
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