To make dynamic labels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anniejacob
    New Member
    • Feb 2007
    • 14

    To make dynamic labels

    hi,


    I am making a dynamic form which i have to put some labels which r 2 b dynamic.n i have to make 'n' number of labels dynamically.

    label me = new label();

    This is the line im using to make it. how do i pass the value of 'n' in the code.
    if someone can help me 2 do this.

    plz help to do this.
    Reply soon........
  • kuzen
    New Member
    • Dec 2006
    • 20

    #2
    Hi,
    I don' know what language you're using. Here is a version in VB
    Code:
            For i As Integer = 0 To n ' as many as you need
                Dim label As New System.Windows.Forms.Label
                Me.SuspendLayout()
                label.Location = New System.Drawing.Point(112, 96 + i * 96) 'you can change the location to your preference, just make sure they don't overlap 
                label.Name = "label" + i.ToString
                label.TabIndex = 0
                label.Text = "label" + i.ToString
                Me.Controls.Add(label)
            Next
    I hope this helps

    Comment

    • anniejacob
      New Member
      • Feb 2007
      • 14

      #3
      hi,

      Thank u so much 4 the reply but my prob got solved before that. but this was almost wat i wrote but in C#

      Comment

      Working...