Results 1 to 3 of 3

Thread: [2005]CheckedChanged&CheckStateChanged events fire B4 removing handler in Load event

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    40

    Unhappy [2005]CheckedChanged&CheckStateChanged events fire B4 removing handler in Load event

    I've discovered that the CheckedChanged and CheckStateChanged events fire before I'm able to remove the handlers in the Form_Load event.

    This occurs when the properties for the Checked and CheckState are changed from the default settings at design time.

    Could this possibly be a bug in the code? I thought the ability to remove the handlers was to allow unimpeded changes to data in the form on load, such as loading the data into the control, before the form is activated.

    Any thoughts?

    As a workaround I suppose I can change the default properties in the Load event after the handler was removed.

    Thanks,
    Vic

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005]CheckedChanged&CheckStateChanged events fire B4 removing handler in Load event

    Thats odd. Well, have you considered using a boolean flag instead?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: [2005]CheckedChanged&CheckStateChanged events fire B4 removing handler in Load event

    There's no reason that you should be removing event handlers in the Load event handler of your form. You must have added the event handlers in the designer for them to require removing at that point. If you don't want the event handlers added then don't add them in the first place.

    Open your form in the designer and select the control for which you were removing the event handler in code. Now open the Properties window and press the Events button. Right-click the event of interest and select Reset. The selected event handler is removed. This means that at run time it will never be added so it will not require removal.

    Unless have set the GenerateMember property of the control to False you also could have just gone through the code and removed the Handles clause from the relevant event. You should also be aware that RemoveHandler has no effect on an event handler that has been attached to a variable using a Handles clause. It only works when the event handler was attached to an object using AddHandler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width