
how can I dynamically create checkboxes in VB.NET
Are you adverse to using a datagrid? You can create a
column that is a checkbox and a column that describes what
the checkbox represents.
There may be a way to do what you want, I just don't know
what it is (but would be interested in learning if anyone
wants to post it here).
-Lee
PS. here's a subroutine for adding a checkbox column to a
datagrid:
Private Sub AddDataGridBoolColumnStyle()
Dim myColumn As DataGridBoolColumn = New
DataGridBoolColumn()
myColumn.MappingName = "DataColumnName"
myColumn.HeaderText = "Column Header"
myColumn.Width = 95
DataGrid1.TableStyles
("TableStyleName").GridColumnStyles.Add(myColumn)
End Sub
Quote:
>-----Original Message-----
>Hi,
> I have to create dynamically a variable number of
checkboxes on a form
Quote:
>depending on the RecordCount of a SQL query. Let me
introduce you the exact
Quote:
>problem:
>I have a worker who has a salary. From this salary I must
substract some
>deductions (taxes, insurances, etc.). The checkboxes are
to represent each
>deductions and can be checked or unchecked depending if
the deduction is
>applicable or not to the worker. Each worker can have
different number of
>possible deductions depending on their salary and their
position in the
>company. So a worker could have 3 possible deductions
while another could
>have 10.(I exagerate, but it's just to let you see the
possible difference).
Quote:
>So I must be able to create checkboxes dynamically. And
these checkboxes
>must handle events. (the same process is used for every
checkboxes, so it
>can the same method and I'm pretty sure it must be the
same method)
>I tryed this without success :
>Private WithEvents CHKDeductions() as
system.windows.forms.checkbox
Quote:
>but the compilator wrote "Cannot declare a WithEvents
object as an array" or
Quote:
>something like that. So what is the other way to do it?
In VB6, this problem
Quote:
>was easily solvable using control arrays, but it does not
seem to be like
>this in .NET. And how do i get the Checked property for
each of the
>checkboxes afterward?
>thanks for helping me.
>.