【发布时间】:2011-09-28 00:34:51
【问题描述】:
另请参阅:How to enable a timer from a different thread/class
计时器已分配给一个表单,我想在特定位置启用它,但来自另一个类。我不想公开它
这是我用来访问备忘录的代码
public string TextValue
{
set
{
if (this.Memo.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate
{
this.Memo.Text += value + "\n";
});
}
else
{
this.Memo.Text += value + "\n";
}
}
}
public static void addtxt(string txt)
{
var form = Form.ActiveForm as Form1;
if(form != null)
form.TextValue = txt;
}
【问题讨论】: