Click to See Complete Forum and Search --> : Label.Index, Where did it go????
JohnGH
Jun 26th, 2002, 04:28 AM
I wanted to use multible lables with the index option
like in VB6, but the label doesn't have that property.
What is the best way to do somethin like that?
Form_Load
For I=0 To lblTest.Ubound
lblTest(I).Caption="Test" & I"
Next I
For I=0 To lblTest2.Ubound
lblTest2(I).Caption="Another" & I
Next I
PT Exorcist
Jun 26th, 2002, 07:49 AM
Indexes are not suported in VB.NET
Amit Rave
Jun 26th, 2002, 07:55 AM
Load the lables on run-time as an array of lables.
By doing do, you will be able to set label properties, add events which will be fired by each one of the lables and more.
For example:
'Put the following in the form load event:
Dim i As Integer
Dim Cb As CheckBox
Lst = New Collection()
For i = 0 To 9
Cb = New CheckBox()
Cb.Text = "Line #" & i + 1
Cb.Top = 10 + (Cb.Height) * i
Cb.Left = 5
Cb.Name = "Test" & i
Lst.Add(Cb)
Me.Controls.Add(Cb)
AddHandler Cb.CheckedChanged, AddressOf CheckBoxLine_CheckedChanged
AddHandler Cb.Click, AddressOf CheckBoxLine_Click
Next i
'The code for the events:
Private Sub CheckBoxLine_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Cb As CheckBox
Cb = CType(sender, CheckBox)
Me.Text = Cb.Name
End Sub
Private Sub CheckBoxLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Cb As CheckBox
Cb = CType(sender, CheckBox)
Me.Text = Cb.Name
End Sub
Have fun.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.