Results 1 to 3 of 3

Thread: Label.Index, Where did it go????

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lelystad, Netherlands
    Posts
    73

    Label.Index, Where did it go????

    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?
    Code:
    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

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Indexes are not suported in VB.NET

  3. #3
    New Member
    Join Date
    Oct 2000
    Posts
    2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width