Graphics Help

H

Henry

Hello, the objective was to print a filled circle to the picturebox, and
print the color name to a textbox each 2 seconds. Following is the code I
used, however, I could never see anything except the last item in the
arraylist being printed, tried different ways to iterate through the colors,
different placing of the thread.sleep, but never see anything but the last
color in the array list, appreciate finding out why this doesn't work, or
how to make it work.
Thanks
Henry


private void DrawCirclesColors()
{
ArrayList col = new ArrayList();
col.Add("Black");
col.Add("Blue");
col.Add("GhostWhite");
// IEnumerator enumerator = col.GetEnumerator();
// while (enumerator.MoveNext())

// foreach (string item in col)
for (int x = 0; x< col.Count; x++)
{
Bitmap bm = new Bitmap(250, 250);
Graphics g = Graphics.FromImage(bm);
Brush bw = new
SolidBrush(Color.FromName(col[x].ToString()));
g.FillEllipse(bw, 60, 60, 120, 120);
label1.Text = col[x].ToString();
pictureBox1.BackgroundImage = bm;
Thread.Sleep(2000);
}



}
 
M

marss

Henry said:
Brush bw = new
SolidBrush(Color.FromName(col[x].ToString()));
g.FillEllipse(bw, 60, 60, 120, 120);
label1.Text = col[x].ToString();
pictureBox1.BackgroundImage = bm;

Put here this code:

pictureBox1.Refresh();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top