Arrayed checkbox controls to table

  • Thread starter Thread starter gwboolean
  • Start date Start date
G

gwboolean

Guest
I have a method that is used to create a set of checkboxes and labels to display on a form.

Now I am sure there are much better ways to do this, but this was my best shot.

With frmFileMaster.pnlFileCategory
For I = 1 To 10
If I = 0 Or I = 11 Then intY = 18
If I = 6 Or I = 11 Then
intX = 40
intY += 20
End If
lblCategory(I) = New Label
chkCategory(I) = New CheckBox
chkCategory(I).Font = New Font("Times New Roman", 11, FontStyle.Bold)
'lblCategory(I).Text = CType(SiTechTable.Rows(0).Item(I + 1), String)
lblCategory(I).Text = _FileMasterControlSettings(I + 1)
If _strSetState = "Edit" Then lblCategory(I).ForeColor = Color.White
If _strSetState = "New" Then lblCategory(I).ForeColor = Color.LightGray
lblCategory(I).BackColor = Color.DarkRed
lblCategory(I).AutoSize = True
chkCategory(I).Size = New Size(15, 14)
chkCategory(I).Location = New Point(intX, intY)
lblCategory(I).Location = New Point(intX + 20, intY)
.Controls.Add(chkCategory(I))
.Controls.Add(lblCategory(I))
intX += 120
Next
End With



So when the form is in edit mode, any or all of these checkboxes can be checked or unchecked.

Now where I want to go with this is to save it to a table in a database, which must be done in a different method. This is no problem with the form controls. However, I am unable to figure out how to do this with the checkbox values.

One way I attempted to input a checkbox value into the table, in the other method, was as follows

FileDataRow("blnCategory1") = CBool(lblCategory(1).Text)

When this is done, I get a message indicating:

1568125.jpg

So, how am I to get the checkbox values carried to the row.item?


gwboolean

Continue reading...
 
Back
Top