-
Feb 10th, 2008, 01:30 PM
#1
Thread Starter
Member
[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
-
Feb 10th, 2008, 01:39 PM
#2
Re: [2005]CheckedChanged&CheckStateChanged events fire B4 removing handler in Load event
Thats odd. Well, have you considered using a boolean flag instead?
-
Feb 10th, 2008, 08:19 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|