hello, I create multiple dynamic pictureboxes and it are to many to add them all manually, is there a way I can e.g. use an integer which adds up every time a new picturebox is made. Then I want to add the same code to every picturebox. Now it creates the picturebox and moves it to the next spot and doesn't create a second. I am using this code if its helpfull:
Code I'm using Code:
  1. Dim newimg As PictureBox = New PictureBox
  2.         If imgCounter < 5 Then
  3.             newimg.Height = 65
  4.             newimg.Width = 50
  5.             newimg.Name = "img" & imgCounter
  6.             newimg.Left = 'i want this to be 100 further every time
  7.             newimg.Top = wp1.Location.Y
  8.             newimg.Image = My.Resources.img
  9.             newimg.Visible = True
  10.             newimg.BackgroundImage = My.Resources.Road
  11.             newimg.SizeMode = PictureBoxSizeMode.StretchImage
  12.            
  13.  
  14.  
  15.             Me.Controls.Add(newimg)
  16.             newimg.BringToFront()
  17.             imgCounter += 1
  18.             call TheCodeSub()
  19.         Else
  20.             imgSender.Stop() ' timer
  21.             imgCounter = 0
  22.         End If