javed khan
i have created a form close event handler in that when user clicks it a message displayed "Do you want to save changes" there are three buttons yes,no and cancel when user clicks on cancel form will remain same and message box will close so what to do?
By javed khan in Windows Forms on Apr 16 2009
  • Nishant Kumar
    Apr, 2009 17

    For that we will create a class lets say

    public delegate void DatabaseErrorEvent(object sender, NotifyEvent e);

    public class NotifyEvent :EventArgs
    {
        public string Msg = string.Empty;
       
        public NotifyEvent(string Notice)
        {
            //
            // TODO: Add constructor logic here
            //
            this.Msg = Notice;
        }

        public string msg
        {
            get { return Msg; }
        }

    public class Worker
    {
        public Worker()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public event DatabaseErrorEvent CriticalFailure;

        protected virtual void OnCriticalError(NotifyEvent e)
        {
            if (this.CriticalFailure != null)
            {
                this.CriticalFailure(this, e);
            }
        }

        public void DoWorkAndRaiseEvent( string Msg )
        {
          
            OnCriticalError(new NotifyEvent(Msg));
           
        }


    }
    In another Form where we want to call

    public void obj_CriticalFailure(object sender, NotifyEvent e)
        {

            //string s = e.Msg;
            lblInfo.Text = e.Msg;

        }
       




    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS