Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

ListView change item text

So i have an listview in gui and i want to change text in (lets say column num 2And row 1)
How would i do that ?
I realy want to get 1 line code because i am going to change text within 10 sec like 100 times.

Something like listview.items[row].column[1].text="new text";
If there would be something like that i would be realy happy.
I think something like that should do it :

PHP Code

<?php 
string
[] row1 = { "s1", "s2", "s3" };
listView1.Items.Add("Column1Text").SubItems.AddRange(row1); 

🤝
(Apr 8, 2016 12:10 PM)GuRuHaX Wrote:  I think something like that should do it :

PHP Code

<?php 
string
[] row1 = { "s1", "s2", "s3" };
listView1.Items.Add("Column1Text").SubItems.AddRange(row1); 

🤝

This ADD's a new ListViewItem to the ListView -- not what he wanted.

OP: Column 2, Row 1, translates to ListViewItem index 0, and SubItem index 1...
Code
listview.Items[0].SubItems[1].Text = "new string";

I believe the subitem indexing is preserved as well even with column re-ordering.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Apr 10, 2016 12:07 AM)0xDEAD10CC Wrote:  This ADD's a new ListViewItem to the ListView -- not what he wanted.

OP: Column 2, Row 1, translates to ListViewItem index 0, and SubItem index 1...
Code
listview.Items[0].SubItems[1].Text = "new string";

I believe the subitem indexing is preserved as well even with column re-ordering.

Oops 😊 indeed , sry for the misunderstanding !

🤝
(Apr 8, 2016 11:42 AM)IAmBabyFinn Wrote:  Something like listview.items[row].column[1].text="new text";

Switch column with SubItems and fix the casing and you've got it. ^^
(Apr 10, 2016 12:07 AM)0xDEAD10CC Wrote:  This ADD's a new ListViewItem to the ListView -- not what he wanted.

OP: Column 2, Row 1, translates to ListViewItem index 0, and SubItem index 1...
Code
listview.Items[0].SubItems[1].Text = "new string";

I believe the subitem indexing is preserved as well even with column re-ordering.

I thank you for this . This had gotten me so much headache because other way i found was to loop all items and check if it is in column 1 and row1.
Thanks :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Mr.MagnificentFeb 26, 2019 09:40 AM 7 331 Feb 26, 2019 09:40 AM
Last Post: itcorp
[.NET] by AspectModdingDec 9, 2016 06:20 AM 2 164 Dec 9, 2016 06:20 AM
Last Post: AspectModding
[.NET] by 270zFeb 24, 2016 05:33 PM 7 227 Feb 24, 2016 05:33 PM
Last Post: Ninja