Results 1 to 3 of 3

Thread: VB .NET 2003 Check Box Even Called on Load

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    VB .NET 2003 Check Box Even Called on Load

    I am using VB .NET 2003. The CheckedChanged even is being called when the form loads because it is the default option checked. What is a nice clean way to avoid this? Is there another event I should use? Should I disable until the end of form load? What is a good way to fix this? Thanks.

    VB Code:
    1. Private Sub _optFont_0_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2. Handles _optFont_0.CheckedChanged
    3.         theFontSize = 8.25
    4.     End Sub

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Re: VB .NET 2003 Check Box Even Called on Load

    Noone knows how to use a check box? Lol, this is bad.
    Quote Originally Posted by rex64
    I am using VB .NET 2003. The CheckedChanged even is being called when the form loads because it is the default option checked. What is a nice clean way to avoid this? Is there another event I should use? Should I disable until the end of form load? What is a good way to fix this? Thanks.

    VB Code:
    1. Private Sub _optFont_0_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2. Handles _optFont_0.CheckedChanged
    3.         theFontSize = 8.25
    4.     End Sub

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB .NET 2003 Check Box Even Called on Load

    It's quite simple. Declare a Boolean variable at the class level to indicate whether the form has been initialised. Set this variable at the end of your Load event handler. Test this variable in your CheckChanged event handler and do nothing if it isn't set.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width