Hey all,

I'm recreating an old board game on the computer using VB. This game has player tokens that have to be displayed on the screen. I used the "Component" class to create the definition of a player, from which I instantiate a player for each player that is playing. Within the class, I define a picturebox with an image inside to represent the player token.

Here's the problem - I can't get the token pictureboxes to appear on the screen. I am almost positive that it is because I am not putting them in a container. I tried to pass the form as a container to put the tokens on, but it errors out when I try to do that, saying it is an invalid cast. Here is the code for a new Player:
VB Code:
  1. Public Sub New(ByVal Container As System.ComponentModel.IContainer, ByVal tempCash As Integer, ByVal tempPlaying As Integer, ByVal tempColor As String)
  2.         MyClass.New(tempCash, tempPlaying, tempColor)
  3.  
  4.         'Required for Windows.Forms Class Composition Designer support
  5.         Container.Add(Me)
  6.     End Sub
  7.  
  8.     Public Sub New(ByVal tempCash As Integer, ByVal tempPlaying As Integer, ByVal tempColor As String)
  9.         MyBase.New()
  10.  
  11.         'This call is required by the Component Designer.
  12.         InitializeComponent()
  13.  
  14.         'Add any initialization after the InitializeComponent() call
  15.         cash = tempCash
  16.         colorName = tempColor
  17.         playing = tempPlaying
  18.         If tempColor = "Red" Then
  19.             token.Image() = System.Drawing.Bitmap.FromFile("redpiece.png")
  20.             color = System.Drawing.Color.FromArgb(255, 128, 128)
  21.         ElseIf tempColor = "Blue" Then
  22.             token.Image() = System.Drawing.Bitmap.FromFile("bluepiece.png")
  23.             color = System.Drawing.Color.FromArgb(128, 128, 255)
  24.         ElseIf tempColor = "Green" Then
  25.             token.Image() = System.Drawing.Bitmap.FromFile("greenpiece.png")
  26.             color = System.Drawing.Color.FromArgb(128, 255, 128)
  27.         ElseIf tempColor = "Yellow" Then
  28.             token.Image() = System.Drawing.Bitmap.FromFile("yellowpiece.png")
  29.             color = System.Drawing.Color.FromArgb(255, 255, 128)
  30.         ElseIf tempColor = "Black" Then
  31.             token.Image() = System.Drawing.Bitmap.FromFile("blackpiece.png")
  32.             color = System.Drawing.Color.Gray
  33.         ElseIf tempColor = "White" Then
  34.             token.Image() = System.Drawing.Bitmap.FromFile("whitepiece.png")
  35.             color = System.Drawing.Color.White
  36.         Else
  37.             System.Console.WriteLine("Error in New() in Player.vb while trying to assign a color to the token")
  38.         End If
  39.  
  40.         If playing = 1 Or playing = 2 Then
  41.             token.Visible = True
  42.             token.Location = spacesArray(0).getLocation
  43.         End If
  44.     End Sub
My error message ("Error in New()...") doesn't come up in the console, so it is assigning a picture to the token, and playing always = 1 at this point (eventually 0 will be not playing, 1 will be a human playing, and 2 will be a CPU playing). Any suggestions? Should I create a container on the form (like a panel) that is transparent and use that for the token positions?