Question about a group of checkboxes, and using selection for data insert

Posted on 2006-05-01
Last Modified: 2010-04-23
I have a group of checkboxes that I need to use for assigning value to a database insert. There is 7 check boxes that the user can select from which corresponds to a type of gauge that I am inserting into the database inventory. Is there a way to group these boxes together, so that I can use a selected item in the group as opposed to using a huge IF loop to use that for selection?


Question by:bradbritton
    LVL 3

    Expert Comment

    Use an ArrayList to store checkbox objects that has Checked property is true. For example: Add 2 checkbox checkbox1, checkbox2, 1 label label1:
    Public Class Form1
        Dim cc As New ArrayList
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        End Sub

        Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged
            If CType(sender, CheckBox).Checked Then cc.Add(sender) Else cc.Remove(sender)
            Label1.Text = ""
            For i As Integer = 0 To cc.Count - 1
                Label1.Text += cc.Item(i).name
        End Sub
    End Class
    LVL 5

    Accepted Solution

    If you are using VB 2005 you can use the CheckBoxList or RadioButtonList controls.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 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

    13 Experts available now in Live!

    Get 1:1 Help Now