Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2008, 10:11 AM
Authorized User
 
Join Date: Jun 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Avoid auto-trigger formevents during formload

Hi,

During formload vb triggers all kinds of events including events like check state changed of checkboxes. But I only would like to update my form during formload and don't want code inside these events got executed.

Ofcoarse I could turning off and on a boolean variable at start and and of the formload, but that's seems to be a solution like 'goto 209', so I'm looking for a better one. One that is universal to all projects.

In VB6 my solution to this problem was to let events (that would be fired by formloads) question if they themselves were the activecontrol or not. If not they were fired during formload, if yes they were fired by the user (and would execute the related code).

Somehow in vb.net checkboxes somehow always return true on the 'me.activecontrol is controlobj'-solution. So that's no reliable solution anymore.

So my question is; how do you prevent your control-events-code from being executed by the formload?

Another solution that I thought of is to remove all control-eventhandlers at the start of the formload and put them all back at the end of the formload event.

I understand it's a far away solution to this problem, but I wonder if it's possible.

For this reason for some time now I'm looking for a way to do this... remove all event-handlers of a fom in runtime, but unfortunately I didn't find usable info on google yet.

What I díd find was code to remove all handlers for one particular event, but what I want to do is remove all handlers for ALL events of a form (like click and leave events).

Next to that I'd like to store the handles in a temporarly list to restore the handles later.
I want to do this to have some universal solution to avoid the automatic triggers of checkboxes/radionbuttons etc. during formloads.

Thanx in advance again!

 
Old September 9th, 2008, 03:33 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

It is pretty standard to create aform-level boolean, and set it to True once it is OK to let the events run. Then you put in each event that should wait: If Not <var> Then Exit Sub.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Refresh and Auto Delete deontae45 VB.NET 2002/2003 Basics 1 September 29th, 2006 04:53 PM
how to avoid logon justin_min Crystal Reports 0 November 30th, 2004 02:05 PM
Trying to avoid duplicacy aspadda Excel VBA 0 April 23rd, 2004 12:59 PM
How do I Avoid a ROLLBACK when... wmhhodson SQL Server 2000 1 October 31st, 2003 01:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.