MDI sub-window message communication

xiaoxiao2021-03-06  39

Using system;

Namespace Vavic {///

/// When the information change is notified of other windows to reload data /// How to use: 1) Notification information Change /// notify.instance (). SendMessage (100, "Form1 Activate test notify event "); ////// wherein the first parameter is the information number, the second parameter is information description /// 2) Collection information /// How to use, add the following statement to each FORMLOAD event // / Notify.instance (). OnNotifyEvent = new notify.notifyEvent (onnotifyEvent); ////> Write the following method for reloading data ///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)); ///} /// public class Notify {protected static Notify m_notify = null; public delegate void NotifyEvent (object sender, NotifyEventArgs e); public event NotifyEvent OnNotifyEvent; protected Notify () {// // Todo: Add constructor logic here //}

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_strime = 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; #ndregion}}}

转载请注明原文地址:https://www.9cbs.com/read-67985.html

New Post(0)