addhandler and removehandler - work as advertised?

  • Thread starter Thread starter jeff
  • Start date Start date
J

jeff

I have code in a form load (and I tried it in New() too) that says:

"Removehandler me.comboCity.SelectedIndexChanged,
me.comboCity_selectedIndexChanged"

I needed to disable processing of the combo being changed while the control
binds to the arraylist data via standard data binding during form load.

Then after the data loads and the form is done I code:

"AddHandler me.comboCity.SelectedIndexChanged, AddressOf
me.comboCity_selectedIndexChanged"

But the event still fires while the databinding is taking place, why? The
event was supposed to be disabled?

Thanks,

Jeff
 
hi
well i dont know how it is done in VB.NET syntax..... in C# i am doing this way...

created the handler object......... EventHandler ehDBCombo = new EventHandler(XYZMethod());

and whenever required...
DBCombo.SelectedIndexChanged -= ehDBCombo;
..
..
.. WRITE UR CODE HERE
..
..
DBCombo.SelectedIndexChanged += ehDBCombo;

rajeev
 
hi, jeff,
try to rewrite the statment in
RemoveHandler me.comboCity.SelectIndexChanged, addressof
me.combocity_selectedindexchanged
for more information ,you may read the following topic in msdn

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbls7/html/vblrfVBSpec7_3.htm

best regards,

Jonny
 
The RemoveHandler call is missing an AddressOf
(compare it to your AddHandler call)

Turn on both Option Explicit and Option Strict and
you should get a compiler error

/claes
 
Just out of curiosity, does your comboCity_selectedIndexChanged method have
a Handles clause at the end? If so, you probably need to remove this as it
may be adding an additional handler to your event.

Just a thought.

Chris
 
Back
Top