1
Reply

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?

javed khan

javed khan

Apr 16, 2009
5.3k
0

    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;

        }
       




    Nishant Kumar
    April 17, 2009
    0