Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created an event in c# but my event is not showing in the property grid in c#. please i need an immediate help
this is my event code:
C#
public Timer _timer = new Timer();
        public event EventHandler TextChangedDelayed;
        //public event

        public DelayedText()
        {
            _timer.Interval = 1000;
            _timer.Tick +=new EventHandler(_timer_Tick);
        }

        private void _timer_Tick(object sender, EventArgs e)
        {
            _timer.Stop();
            onTextChangedDelayed();
        }
        protected override void OnTextChanged(EventArgs e)
        {
            base.OnTextChanged(e);
            _timer.Start();
            _timer.Stop();
        }

        protected virtual void onTextChangedDelayed()
        {
            if (TextChangedDelayed != null)
            {
                TextChangedDelayed(this, EventArgs.Empty);
            }
        }

        public int TextChangedDelayedInterval
        {
            get { return _timer.Interval;  }
            set { _timer.Interval = value; }

        }
    }
Posted

1 solution

I don't know why would you need such a strange thing with a timer, to, me, it looks like some kind of abuse, but it's up to you. Your problem is quite clear: _timer.Start(); is never called. Yes, it is called in OnTextChanged, but OnTextChanged itself will never be called because it is only called by a timer event handler, which is never called because the timer is never started.

In hope I made it clear for you. But please don't ask me "what to do": I would never do such weird thing and have no idea what you are trying to achieve with that. You can just fix the problem I just described.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900