auto fire of items events on initilization (check/radio buttons)

B

Brian Henry

How can you stop the check changed event from fireing during the
initilization of a form? I have about 4 radio and check boxes on the form,
and when the form is initilizing, the one that is marked as checked during
the initilization (when InitializeComponent is called) always fires it's
check changed event, which I don't want it do to.. how can you prevent this?
thanks
 
D

Domenico Daraio

you want don't view the chacked, you can setting for all radio or check
enable false...

bye
domenico
 
C

Cor

Hi Brian,

I think we all do that with a flag/bool/switch whatever you name that, that
you set at the end of the load form event to true. This is the most wide
solution I've seen in this newsgroups for that.

I hope that helps?

Cor
 
K

Ken Tucker [MVP]

Hi,

There is no way to prevent the event from happening. Here is a
possible work around.

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged

Static bIgnore As Boolean = True

If Not bIgnore Then

' Your code goes here

Debug.WriteLine("Checked changed")

End If

bIgnore = False

End Sub



Ken
 
B

Brian Henry

that's pretty much my hack i had in place, was hopeing there was a switch i
was missing that did it already :)
 
H

Herfried K. Wagner [MVP]

* "Brian Henry said:
How can you stop the check changed event from fireing during the
initilization of a form? I have about 4 radio and check boxes on the form,
and when the form is initilizing, the one that is marked as checked during
the initilization (when InitializeComponent is called) always fires it's
check changed event, which I don't want it do to.. how can you prevent this?
thanks

Add the handler to the event after changing the state. Have a look at
the 'AddHandler' and 'RemoveHandler' keywords.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top