CheckedChanged after load form

Posted on 2008-11-12
Last Modified: 2012-05-05
I have radiobutton controler on my form. I would like to ask why on load form is triggered my code which handles only checkedchange metode.
Private Sub rdgDisplayAspectRatio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdg1DisplayAspectRatioBox.CheckedChanged, rdg1DisplayAspectRatioPan.CheckedChanged, rdg1DisplayAspectRatioStretch.CheckedChanged, rdg1DisplayAspectRatioPanScan.CheckedChanged

        If CType(sender, RadioButton).Checked Then

            frmMain.frmvideo1.VideoGrabber1.Display_AspectRatio = CType(CType(sender, RadioButton).Tag, VidGrab.TAspectRatio)

        End If

    End Sub

Open in new window

Question by:patrikmichnac
    LVL 62

    Accepted Solution

    Hello patrikmichnac,

    That is because one of the radio buttons is set to Checked at design time or you are changing it at form load. You can do the following to get around it.

    Public Class Form1

        Private FormIsLoaded As Boolean = False

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            FormIsLoaded = True

        End Sub

        Private Sub rdgDisplayAspectRatio_CheckedChanged(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles rdgDisplayAspectRatio.CheckedChanged

            If Not FormIsLoaded Then Return

            'Do whatever here

        End Sub

    End Class


    LVL 62

    Expert Comment

    by:Fernando Soto
    Hi TheLearnedOne;

    My reason for this objection is - I have posted a solution that should work.

    LVL 62

    Expert Comment

    by:Fernando Soto
    A solution to this question was posted above

    Thanks you;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now