0

I am a student currently and I am quite new to C#, I am currently working on a school project to create a game but I am facing a PictureBox stacking problem. PictureBox that I initialize first are at the front, and all other PictureBox I initialize are behind it, it looks something like this,

http://imgur.com/8m36YgC

Is there anyway that I can bring the photo up? this is how my code looks like.

handCardString = new List<string>();
handCardString = h.displayHand();
handCards = new PictureBox[99];

int q = 0;
int loca1 = 439;

foreach (string s in handCardString)
{
    handCards[q] = new PictureBox();
    String r = String.Format("c:/Users/youhj/Desktop/CA1/Cards/{0}.jpg",s);
    Image ph = Image.FromFile(@r);
    handCards[q].Image = ph;
    pCardPhoto.Add(handCards[q]);
    pCardPhoto[q].Location = new System.Drawing.Point(loca1, 383);
    pCardPhoto[q].Size = new System.Drawing.Size(100, 126);
    pCardPhoto[q].SizeMode = PictureBoxSizeMode.StretchImage;
    pCardPhoto[q].BorderStyle = BorderStyle.None;
    this.Controls.Add(pCardPhoto[q]);
    loca1 += 20;
    q++;
}
CodeCaster
  • 147,647
  • 23
  • 218
  • 272

1 Answers1

0

WinForms controls generally don't stack and there is no true support for transparency. If you want custom rendering of images to support this use then author a custom Control with your own OnPaint routine.

Another option is to use WPF which is more flexible in this regard, though has a different programming model and a steeper learning curve.

Dai
  • 141,631
  • 28
  • 261
  • 374