By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Move Dynamically generated labels

100+
P: 138
I have dynamically generated labels in my code. It is working fine. I want to change the position of those labels.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3.         Try
  4.             Dim c As Integer = 10
  5.             Dim l As Integer = 0
  6.             Dim lft As Integer = 20
  7.             For i = 1 To c
  8.                 For j = 1 To 8
  9.                     If l < c Then
  10.                         labelDemo = New Windows.Forms.Label
  11.                         labelDemo.Name = "label"
  12.                         labelDemo.Text = "Move"
  13.                         labelDemo.Left = lft
  14.                         labelDemo.AutoSize = True
  15.                         labelDemo.BackColor = Drawing.Color.Aquamarine
  16.                         Me.Controls.Add(labelDemo)
  17.                         l = l + 1
  18.                         lft = lft + 80
  19.                     End If
  20.                 Next
  21.  
  22.  
  23.             Next
  24.  
  25.             Me.ResumeLayout()
  26.         Catch ex As Exception
  27.         End Try
  28.     End Sub
  29.  
The above code will generate the labels. I am not able to move those labels. Any help will be helpful. I found some links that helps to move a label, but i want to move those dynamically generated labels.
May 10 '16 #1
Share this Question
Share on Google+
2 Replies


100+
P: 299
Do you want to move a single label or move every label at the same time? The answer to this question greatly changes the code necessary.
May 10 '16 #2

100+
P: 138
I need to move a label at a time. just need to interchange the position of some labels as needed.
May 11 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.