preceding with caution - with regards to REMOVEHANDLER and ADDHANDLER

MBHEY131
MBHEY131 used Ask the Experts™
on
My Project "WHICH IS ALREADY A YEAR BEHIND SCHEDULE" - mostly because of rewrites, mis-understandings, mis-interpretations, etc
I am a little un-nerved about starting to REMOVE the HANDLES clause in some of my event procedures - although it fits the current purpose -

 wouldn't it also create code that should be auto-run and now it's not being run - because the HANDLES clause is no longer present?
AND YOU WOULD HAVE NO WAY OF KNOWING THAT - OR IT WOULD BE DIFFICULT TO FIGURE OUT - MORE DEBUG NIGHTMARES

which could cause say not properly formatted data in databases, etc - as an example with the .cellvaluechanged event?

just trying to avoid more rework - because I'm quite a ways along with this FIRST vb.net project and time is running out!

I guess what I'm trying to find out is - Is there a way to not touch the HANDLES clause and IN CODE tell the system not to run the said event!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:
I don't understand your concern.

You write code in the event handlers for the events you want to do something specific. Sometimes you need to add some code to these handlers to bypass them. For example, you might check on the first line of your handler if your grid's DataSource is nothing to return.

Author

Commented:
that's a good point - nothing in the datasource then go out of the sub -but then that code would get launched for every cell that gets filled "WHICH IS WHAT IS HAPPENING NOW"- in the case of the .CELLVALUECHANGED event - when the FORM LOAD code is run - as is my limited understanding of VB.NET - well I can't over think this anymore - I like the REMOVEHANDLER and ADDHANDLER with the HANDLES clause removed - and will have to adjust future code as needed - thanx for the input!
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Place a breakpoint in your event handler and check the call stack to see what causes the event to be raised.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Author

Commented:
I'm not going to call the event .cellvaluechanged at FORM LOAD at all - have DELETED - HANDLES clause! - but 1 more question and I promise I'm done with this issue -

Where would you put the ADDHANDLER - once the FORM gets loaded
My first choice will be at the very end of the FORM LOAD event!
Is there a better way?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
the end of Form_Load is usually the best place
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
Or it can be after you loaded the grid for the first time (if grid events)

Author

Commented:
ended up moving my code to the .mouseup event - and all works great!
 nice to know a little something about the events!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial