Check box control event events

Hell .net experts,

I am having some trouble with handling events in little app I'm developing.  I've not used .net before so this is all new to me.

I have a form with a ViewTree in which the user can select various nodes.  As the user browses through the nodes, details about the currently selected node are displayed on the form.  One of the values these nodes have is a boolean that I represent as a CheckBox.  The user is allowed to change this value by checking or unchecking the box which then changes the underlying value in the node object.

The event I'm using to handle this is CheckChanged, and it works ok if I just check and uncheck on a single node.  My problem is that the CheckChanged event is also triggered when a user selects a node which has a different check status than the previous.  In this case I dont want anything to happen, I understand why it's being triggered because, of course, the check box value has changed.  But it has been changed because we are now looking at a different node, not because the user is trying to change the current node's status.

Anyone got any ideas on how to get around this?  Are there other more appropriate events I could use?

Thanks for any input.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
More appropriate events for detecting a user change versus a program change is to use the MouseDown (left-click) and KeyDown (space bar) events.


Here is where I found good examples for getting started in VB.Net


Link for ASP programs... 
Hi Tommy,

Can;t think of another event to fire instead, but the only work around is to have a loading flag.


have a private variable boolean variable that is set to false.

dim mbLoading as boolean = false

Then when you set the checkbox value in code, set mbloading = true and then set it back to false after setting it.


' Load data
mbLoading = True
checkbox1.checked = {Value}
mbLoading  = false

Then in your CheckChanged event put your code that runs inside an if statement.

If mbloading = false then
   ' Do your stuff
End If

That will get round the problem, can;t think of any other way.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.