Change Column in ListView

My application contains a ListView with the files that I am processing, and has 3 columns: file name, length and status. Inside the for loop, I process the file after the file and in this case I want to change the wait state column, which is the value at the beginning of the process . is it possible to change one column?

lvFiles is my ListView

 for (int i = 0; i < lvFiles.Items.Count; i++) { //here i am do things with my file } 

Here I add the files to my ListView:

 ListViewItem item = new ListViewItem(new string[] { new FileInfo(filePath).Name, duration, "Waiting" }); 
+6
source share
2 answers

Use the SubItems property of ListViewItem :

 foreach(ListViewItem item in lvFiles.Items) item.SubItems[2].Text = "Waiting"; 
+4
source

You can try something like this if you know a specific column, for example, the Address will be colString [2] you can make one line

 string[] colString = new string{ "Starting", "Paused", "Waiting" }; int colIndex = 0; foreach (ColumnHeader lstViewCol in lvFiles.Columns) { lstViewCol.Text = colString[colIndex]; colIndex++; } 

for one column, you stated that you want a third column, then you could something like this

 lvFiles.Colunns[2] = "waiting"; 
+2
source

All Articles