Check box control event events

Posted on 2004-12-01
Last Modified: 2010-04-24
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.

Question by:TommyV10
    LVL 96

    Expert Comment

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

    LVL 27

    Expert Comment


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


    Link for ASP programs...
    LVL 1

    Accepted Solution

    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.



    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now