[Last Call] Learn how to a build a cloud-first strategyRegister Now


CheckedChanged after load form

Posted on 2008-11-12
Medium Priority
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
  • 3
LVL 64

Accepted Solution

Fernando Soto earned 2000 total points
ID: 22942210
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 64

Expert Comment

by:Fernando Soto
ID: 23187160
Hi TheLearnedOne;

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

LVL 64

Expert Comment

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

Thanks you;

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

830 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