Disable programmatically raised events

  • Thread starter Thread starter Max Weber
  • Start date Start date
M

Max Weber

Hello,

Is there a way to avoid an event to be raised programmatically ? As an
exemple : ScrollBar.ValueChanged is raised when the value of the
scrollbar changes, whenever the user moved the slider or some code has
been executed which changed the value of the scrollbar. How to avoid
the second case ?
 
Hi,

I can think in two ways to do it,

or you can override the event and do not call to the base event or if you
need more control you can override WndProc and catch and process the message
avoiding to trigger any event.

Hope this helps
Salva
 
I do it simply. I gave up disabling events

bool ScrollIsBusy = false;

private MyScrollMoveEvent(event related stuff)
{
if (ScrollIsBusy) return
ScrollIsBusy = true;
try
{
DoSomethingElse();
}
finally
{
ScrollIsBusy = false;
}
}
 
Back
Top