title: How do I load an image on a custom object which inherits the picturebox?
body: <p>I'm trying to write a program which has an expandable image feed that keeps adding pictures as I go.  Before I bite off that chunk I'm just trying to get test going with a custom image class which will hold a little bit of extra info on top of the <code>picturebox</code> object.  The issue I'm having is that my object (<code>oSlideItem</code> as <code>clsSlideItem</code>) which inherits the <code>picturebox</code> doesn't seem to load a picture at run time.  I've tried two different methods which are mentioned in help and on this forum and I can't seem to get a picture at run time.  I haven't found anything that mentions my specific situation which is inheriting the <code>picturebox</code>.</p>
  
  <p>I tried setting the image location and size properties before loading the picture, didn't change anything.</p>
  
  <p>Are there some extra steps I need to do in order to initiate the picturebox image since I am using the functionality in an inherited state instead of a native picturebox object ?</p>
  
  <p>I am also putting these image holding objects into a collection as you can see.  I tested loading a picture without putting it into a collection and nothing changed so I don't think that is the issue.  I am Assuming that once I add an object to a collection that the object inside the collection and the object outside the collection are decoupled.  I didn't do a good test for that yet.</p>
  
  <pre><code>Public Class clsSliders
  Private clFeedItems As New Collection 'collection of all feed items
  Private oFeed As New clsFeed 'feed organizer layer
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      'build Feed
      Dim oSlideItem As clsSlideItem 'feed item layer
  
      'make collection of slider objects
      oSlideItem = New clsSlideItem
      oSlideItem.setRank(1, oFeed)
      oSlideItem.ImageLocation = "C:\Users\nathan\Pictures\Chicago_River_from_Lake_Street_bridge.jpg"
      oSlideItem.Load()
  
      clFeedItems.Add(oSlideItem, 1)
  
      oSlideItem = New clsSlideItem
      oSlideItem.Image = Image.FromFile("C:\Users\nathan\Pictures\ReindeerPowerLines.png")
      oSlideItem.setRank(2, oFeed)
  
      'add to collection
      clFeedItems.Add(oSlideItem, 2)
  
      oSlideItem = New clsSlideItem
      oSlideItem.Image = Image.FromFile("C:\Users\nathan\Pictures\TianmenMountain.jpg")
      oSlideItem.setRank(3, oFeed)
  
      'add to collection
      clFeedItems.Add(oSlideItem, 3)
  
  End Sub
  
  'other subs and properties
  End Class
  </code></pre>
  
  <p>and my second class:</p>
  
  <pre><code>Public Class clsSlideItem
  Inherits PictureBox
  
  Private iFeedRank As Integer 'current rank position
  
  Public Sub setRank(rank As Integer, oFeed As clsFeed)
      If Not IsNothing(oFeed) Then
          Me.Left = oFeed.Left(rank)
          Me.Top = oFeed.Top(rank)
          Me.Width = oFeed.Width(rank)
          Me.Height = oFeed.Height(rank)
          iFeedRank = rank
      End If
  End Sub
  
  'other subs and properties
  End Class
  </code></pre>
  
  <p><code>oFeed</code> as <code>clsFeed</code> is basically a structure which I wrote as a class so that I can have extra functionality.  It's not really in the scope of this issue since that part of the code is working. I didn't include it because I didn't want to clutter up this post.</p>