Enable Button If At Minimum One CheckBox Is Checked.

Posted on 2010-01-08
Last Modified: 2012-05-08
I think the subject says it all.  I have a form with 5 CheckBoxes on it and a Button.

I need the button to be enabled if at minimum one CheckBox is checked.
If no CheckBoxes are checked out of the 5 then the Button is NOT enabled

I think that I have done this one before but can't locate the code in my library...
Question by:H-SC
    LVL 85

    Accepted Solution

    There are soooo many ways you could do it.

    If you only have 5 CheckBoxes and this isn't likely to change then you could simply hard-code it:
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Button1.Enabled = False
        End Sub
        Private Sub cb_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged, CheckBox5.CheckedChanged
            Button1.Enabled = CheckBox1.Checked OrElse CheckBox2.Checked OrElse CheckBox3.Checked OrElse CheckBox1.Checked OrElse CheckBox4.Checked OrElse CheckBox5.Checked
        End Sub
    End Class

    Open in new window

    LVL 1

    Author Comment


    This works just fine for me.  Many thank u's

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now