PC Review


Reply
Thread Tools Rate Thread

Creating and displaying a two dimensional array of picturebox

 
 
Ahmed El-Daly
Guest
Posts: n/a
 
      5th Aug 2003
Hi,

The code attached seems to create the pictureboxes but they fail to
display on the form. The items displayed are supposed to be cards from
cards.dll. The code works fine if I provide the hdc of the form
itself, or of a PictureBox that I create myself in the designer.

PictureBox[,] CardFrame = new PictureBox[4, 13];
//PictureBox pictureBox1 = new PictureBox();

private void button1_Click(object sender, System.EventArgs e)
{
int ypos;
Cards yarab = new Cards();
IntPtr hdc;
Graphics hdcobject;
for (int z=0; z<4; z++)
{
ypos = 0;
for (int y=0; y<13; y++)
{
this.CardFrame[z,y] = new PictureBox();
//this.CardFrame[z,y].Visible = true;
/*this.pictureBox1.Size = new Size(50,100);
this.pictureBox1.BorderStyle = BorderStyle.Fixed3D;*/
hdcobject = this.CardFrame[z,y].CreateGraphics();
hdc = hdcobject.GetHdc();
yarab.DrawCard(hdc, 0, 0, yarab.PlayerHand[z, y], 0, 0);
hdcobject.ReleaseHdc(hdc);
ypos += 30;
this.CardFrame[z,y].Location = new Point(z * 100, ypos);
this.Controls.Add(this.CardFrame[z,y]);
//MessageBox.Show((Convert.ToString(this.Controls.Count)));
if(y==5)
MessageBox.Show("5");
else if(y==10)
MessageBox.Show("10");
}
}
//this.Controls.AddRange(new Control[]{this.CardFrame});
MessageBox.Show("done!!");
//this.pictureBox1.CreateGraphics().ReleaseHdc(hdc);
//yarab.DrawCard(hdc, 0, 0, 22, 0, 0); works fine!
//yarab.DrawCard(hdc, 0, 100, 22, 60, 0); this is not working yet!
//yarab.DrawCard(hdc, 0, 200, 22, 2, 0); works fine!
}
}
}

Thank you very bery bery much!!
 
Reply With Quote
 
 
 
 
Ahmed El-Daly
Guest
Posts: n/a
 
      6th Aug 2003
Hi,

I did not receive any responce. Am I posting to the wrong group? If I
am, please lead me to the correct group. If you need any clarification
to the code I provided, I'd be more than happy to provide it. I
thought that this card game would be a good way for me to learn about
c#.

Thanks,
Ahmed


(E-Mail Removed) (Ahmed El-Daly) wrote in message news:<(E-Mail Removed)>...
> Hi,
>
> The code attached seems to create the pictureboxes but they fail to
> display on the form. The items displayed are supposed to be cards from
> cards.dll. The code works fine if I provide the hdc of the form
> itself, or of a PictureBox that I create myself in the designer.
>
> PictureBox[,] CardFrame = new PictureBox[4, 13];
> //PictureBox pictureBox1 = new PictureBox();
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> int ypos;
> Cards yarab = new Cards();
> IntPtr hdc;
> Graphics hdcobject;
> for (int z=0; z<4; z++)
> {
> ypos = 0;
> for (int y=0; y<13; y++)
> {
> this.CardFrame[z,y] = new PictureBox();
> //this.CardFrame[z,y].Visible = true;
> /*this.pictureBox1.Size = new Size(50,100);
> this.pictureBox1.BorderStyle = BorderStyle.Fixed3D;*/
> hdcobject = this.CardFrame[z,y].CreateGraphics();
> hdc = hdcobject.GetHdc();
> yarab.DrawCard(hdc, 0, 0, yarab.PlayerHand[z, y], 0, 0);
> hdcobject.ReleaseHdc(hdc);
> ypos += 30;
> this.CardFrame[z,y].Location = new Point(z * 100, ypos);
> this.Controls.Add(this.CardFrame[z,y]);
> //MessageBox.Show((Convert.ToString(this.Controls.Count)));
> if(y==5)
> MessageBox.Show("5");
> else if(y==10)
> MessageBox.Show("10");
> }
> }
> //this.Controls.AddRange(new Control[]{this.CardFrame});
> MessageBox.Show("done!!");
> //this.pictureBox1.CreateGraphics().ReleaseHdc(hdc);
> //yarab.DrawCard(hdc, 0, 0, 22, 0, 0); works fine!
> //yarab.DrawCard(hdc, 0, 100, 22, 60, 0); this is not working yet!
> //yarab.DrawCard(hdc, 0, 200, 22, 2, 0); works fine!
> }
> }
> }
>
> Thank you very bery bery much!!

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a multi dimensional array using transpose - Is this the best answer? kimbroughton@westvirginia.com Microsoft Excel Programming 11 19th Jul 2006 05:28 PM
Creating a multi dimensional array =?Utf-8?B?RGlubw==?= Microsoft VB .NET 2 9th Nov 2005 05:39 PM
creating two-dimensional array... =?Utf-8?B?WmVyb1Zpc2lv?= Microsoft C# .NET 3 24th Mar 2005 08:01 PM
Creating datagrid view from an two-dimensional array mirek Microsoft C# .NET 4 23rd Nov 2004 08:42 PM
creating a two dimensional array rguti Microsoft VB .NET 16 17th Jul 2004 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:49 AM.