Results 1 to 5 of 5

Thread: control arrays

  1. #1

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    control arrays

    First of all I DON'T want to use a custom control



    I have a picture box with a line in it
    I want an array of picture boxes with one line control in each

    when I load a new picture box and then a line control, the new line control is loaded into the first picture box
    Code:
    Private Sub Command1_Click()
    Dim i As Integer
    i = Picture1.Count
    Load Picture1(i)
    Picture1(i).Visible = True
    Picture1(i).Top = Picture1(i - 1).Top + Picture1(0).Height
    Load Line1(i)
    Line1(i).Visible = True
    'move teh new line a bit so you can see it
    Line1(i).Y1 = Line1(i - 1).Y1 + 10
    Line1(i).Y2 = Line1(i - 1).Y2 + 10
    End Sub
    How can I load a new line into the new picturebox?
    Another light-hearted post from Guru

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Give this a try.
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim i As Integer
    3.  
    4. i = Picture1.Count
    5. Load Picture1(i)
    6. Picture1(i).AutoRedraw = True
    7. Picture1(i).Visible = True
    8. Picture1(i).Top = Picture1(i - 1).Top + Picture1(0).Height
    9.  
    10. Picture1(i).Line (Line1.X1, Line1.Y1)-(Line1.X2, Line1.Y2)
    11.  
    12. End Sub
    Don't make the line part of an array.

  3. #3

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237
    Sorry , perhaps I should have added that It has to be a line control.
    line method is not suitable

    Thanks anyway!
    Another light-hearted post from Guru

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Well heres the code if you have to use it as part of an array
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click(Index As Integer)
    4. Dim i As Integer
    5.  
    6.     i = Picture1.Count
    7.    
    8.     Load Picture1(i)
    9.     With Picture1(i)
    10.         .AutoRedraw = True
    11.         .Top = Picture1(i - 1).Top + Picture1(0).Height
    12.         .Visible = True
    13.     End With
    14.    
    15.     Load Line1(i)
    16.     With Line1(i)
    17.         Set .Container = Picture1(i)
    18.         .X1 = Line1(0).X1
    19.         .Y1 = Line1(0).Y1
    20.         .X2 = Line1(0).X2
    21.         .Y2 = Line1(0).Y2
    22.         .Visible = True
    23.     End With
    24.  
    25. End Sub

  5. #5

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237
    Perfect!

    Thanks MarkT

    I never realised you could set the container.
    Another light-hearted post from Guru

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