Creating a picture box array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Ciaccio

    Creating a picture box array

    Is there some way to create a picture box as a member of an array? There is
    no "index" property as in the VB 6 image control, and it will not let me
    name it pictureBox(0)

    Thanks

    --
    Jeff Ciaccio
    Physics and AP Physics Teacher
    Sprayberry High School; Marietta, GA
    Blog: http://sprayberry.typepad.com/ciaccio

  • Jeff Ciaccio

    #2
    Re: Creating a picture box array

    I forgot to ask this too. Will all the picture boxes on a form
    automatically be a member of an array? I would like to be able to choose
    them all and set them to not visible (to clear all the pictures from a
    form).

    For each pictureBox in (???)
    .visible = false
    Next


    Comment

    • Tom Shelton

      #3
      Re: Creating a picture box array

      On 2008-06-27, Jeff Ciaccio <noname@noreply .orgwrote:
      Is there some way to create a picture box as a member of an array? There is
      no "index" property as in the VB 6 image control, and it will not let me
      name it pictureBox(0)
      >
      Thanks
      >
      There are no control arrays in VB.NET - but, you can have arrays of controls
      :) It's not a concept supported by the IDE so, you have to write a bit of
      code - for example (warning: air code - syntax and logic errors may exist!):

      Option Strict On
      Option Explicit Off
      Option Infer Off

      Imports System
      Imports System.Drawing
      Imports System.Windows. Forms

      Public Class MyForm
      Inherits System.Windows. Forms

      Private _images() As PictureBox

      Private Sub New ()
      InitializeCompo nent()
      _images = New PictureBox() {PictureBox1, PictureBox2, PictureBox3}
      End Sub

      Private Sub SomeSub ()
      ' do stuff with the pictureboxes
      For Each picture As PictureBox In _images
      ' do stuff with picture
      Next

      _images(0).What Ever = SomeValue
      End Sub
      End Class

      HTH
      --
      Tom Shelton

      Comment

      Working...