this is my problem… I have a Windows Forms with a ListBox and a RichTextBox, and a separate class file with some functions…
I know how to update a simple textbox, but not a listview, because if I use the same code, I get 1 new item for every step of myFunc, and the point is this:
//myFunc loads
var lv = listProcess.Items.Add("This is my item");
//myFunc step1
lv.SubItems.Add("Column2 step1 status");
lv.SubItems.Add("Column3 step1 status");
lv.SubItems.Add("Column4 step1 status");
//myFunc step2
lv.SubItems.Add("Column2 step2 status");
lv.SubItems.Add("Column3 step2 status");
lv.SubItems.Add("Column4 step2 status");
//myFunc ends
//Remove item "lv" from listview.
I hope someone can help me…
form1.cs
public Form1()
{
InitializeComponent();
var func = new System.Threading.Timer(otherclass.myFunc, null, 0, 60000);
}
otherclass.cs
public class otherclass
{
public static void myFunc(object sender)
{
var lv = listProcess.Items.Add("This is my item");
for(int i; i <= x; i++)
// Update lv subitems here
next
// Update richTextBox1 here when all steps are done
}
}
I hope someone can help me because I’m so lost
To your general problem:
So what you need is a dataformat (
List<string>or something more involved) to be returned fromMyFunc().