110,535
社区成员
发帖
与我相关
我的任务
分享
public void WriteMsg(object item)
{
listBox1.Invoke(new Action(() =>
{
if (listBox1.Items.Count > 30)
{
listBox1.Items.Clear();
}
listBox1.Items.Insert(0, item);
}));
}
public delegate void Write(string msg);
public class xxoo
{
public Write write;
public cw(msg)
{
write(msg);
}
}
xxoo x=new xxoo();
x.Write=WriteMsg;
x.cw("admin");
public class BurnTime : Quartz.IJob
{
public void Execute(Quartz.IJobExecutionContext context)
{
//我如何在这里面 可以调窗体的writeMsg的方法? 前提不允许把WriteMsg提出来到类中
// 如果是这样 似乎又得把控件当参数传过去.改动太多.....
}
}
public delegate void Write(string msg);
在from1窗体中定义一个public 的上面的东西
public static Write MyWrite;
并且在from的构造函数(或者加载中赋值)
public Form1()
{
InitializeComponent();
MyWrite = Write;
}
其中Write就是上面操作listbox1的方法.
那么我在别的无参的方法中 使用
namespace.Form1.MyWrite("xxoo");
就可以实现了....
多谢大家回帖...