hey,
I want to create programaticly 100 of checkboxes with names like checkbox(from 1 to 100). Then I should be able to check which one is checked or not. Is is possible to make? In VB 6 it was easy.
Thanks.
Printable View
hey,
I want to create programaticly 100 of checkboxes with names like checkbox(from 1 to 100). Then I should be able to check which one is checked or not. Is is possible to make? In VB 6 it was easy.
Thanks.
Hi,
As you have probably noticed, there is no Index propertyin any of the controls and this is because Collections has replaced them in VB.NET
Have a look at the MSDN help on Collections.
Although more difficult to create, Collections offers a more efficient way than Indexes and is great - once you get used to it.
halu,
i'm a newbie though. but check this out... this might help... if not please let me know...
cheers,VB Code:
Friend WithEvents b As New Button() Dim c(9) As CheckBox Dim WithEvents cc As New CheckBox() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer Dim l As Integer = 16 For i = 0 To 9 cc = New CheckBox() c(i) = cc c(i).TabIndex = i c(i).Name = i.ToString c(i).Text = i.ToString c(i).Location = New Point(24, l) l += 25 Controls.AddRange(New Control() {c(i)}) Next b.Location = New Point(24, l) Controls.AddRange(New Control() {b}) End Sub Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b.Click Dim c As CheckBox Dim s As String = String.Empty For Each c In Me.c If c.Checked = True Then s += c.Name End If Next MsgBox(s) End Sub
--ayan
Cool, It works. Thanks.