|
-
Feb 18th, 2004, 01:25 PM
#1
Thread Starter
Hyperactive Member
How to create indexed controls? [Resolved]
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.
Last edited by Norkis; Feb 18th, 2004 at 10:29 PM.
-
Feb 18th, 2004, 07:11 PM
#2
PowerPoster
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.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 18th, 2004, 09:19 PM
#3
Lively Member
halu,
i'm a newbie though. but check this out... this might help... if not please let me know...
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
cheers,
--ayan
-
Feb 18th, 2004, 10:04 PM
#4
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|