欢迎光临
我们一直在努力

Mdi子窗口间消息通信-.NET教程,评论及其它

建站超值云服务器,限时71元/月

using system;

namespace vavic

{

/// <summary>

/// 当信息更改是通知其他的窗口重新加载数据

/// 使用方法为:1)通知信息更改

/// notify.instance().sendmessage(100, "form1 activate test notify event");

/// 其中第一个参数为信息号,第二个参数为信息描述

/// 2)收取信息

/// 使用方法,在每个formload事件中加入如下语句

/// notify.instance().onnotifyevent += new notify.notifyevent(onnotifyevent);

/// 同时编写如下的方法用于重新加载数据

///protected void onnotifyevent(object sender, notify.notifyeventargs e)

///{

/// if (e.code == notify.companyinfo)

/// system.diagnostics.debug.writeline(string.format(" form1 code={0}, message = {1}", e.code,e.message));

///}

/// </summary>

public class notify

{

protected static notify m_notify = null;

public delegate void notifyevent(object sender, notifyeventargs e);

public event notifyevent onnotifyevent;

protected notify()

{

//

// todo: 在此处添加构造函数逻辑

//

}

public static notify instance()

{

if (m_notify == null)

m_notify = new notify();

return m_notify;

}

public void sendmessage(int code, string message)

{

notifyeventargs e = new notifyeventargs(code, message);

if ( onnotifyevent != null)

onnotifyevent(this, e);

}

public class notifyeventargs : system.eventargs

{

public notifyeventargs(int code, string message)

{

m_ncode = code;

m_strmessage = message;

}

public notifyeventargs()

{

}

protected int m_ncode;

public int code

{

get { return m_ncode;}

set { m_ncode = value;}

}

protected string m_strmessage = string.empty;

public string message

{

get { return m_strmessage;}

set

{

m_strmessage = value;

if (m_strmessage == null)

m_strmessage = string.empty;

}

}

}

#region common infomation

public const int companyinfo = 1;

public const int projectinfo = 2;

public const int taskinfo = 3;

public const int opportunity = 4;

public const int contactor = 5;

public const int employeeinfo = 6;

public const int departmentinfo = 7;

public const int advcityinfo = 8;

#endregion

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Mdi子窗口间消息通信-.NET教程,评论及其它
分享到: 更多 (0)

相关推荐

  • 暂无文章