?
Solved

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

Posted on 2006-05-01
2
Medium Priority
?
159 Views
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?

Thanks,

Brad
0
Comment
Question by:bradbritton
2 Comments
 
LVL 3

Expert Comment

by:maidinhtai
ID: 16578366
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
        Next
    End Sub
End Class
0
 
LVL 5

Accepted Solution

by:
proten earned 2000 total points
ID: 16579490
If you are using VB 2005 you can use the CheckBoxList or RadioButtonList controls.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

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