由于某种原因,这段代码给我带来了一个错误
private void button1_Click(object sender, EventArgs e)
{
treeView1.BeginUpdate();
TreeNode labelnode = treeView1.Nodes[0].Nodes.Add("Label" + labelnum.ToString());
treeView1.EndUpdate();
//create id
string id = "1";
Thread thread = new Thread(new ThreadStart(Worker(labelnode, id))); // it errors out here
thread.Start();
}
private void Worker(TreeNode labelnode, string id)
{
while (true)
{
Thread.Sleep(50);
if (labelnode.IsSelected == true)
{
showProperties("label", id);
}
}
}
我在这里尝试做的是选择
labelnode
时显示属性。如果有人帮助我,我会很高兴和感激
Thread thread = new Thread(() => Worker(labelnode, id));
thread.Start();