How can I draw any thing within "for" loop?

  • Thread starter Thread starter John
  • Start date Start date
J

John

How can I draw any thing within "for" loop? I tried the
below but it doesn't draw anything. What should I do?

****
Code
****

Graphics g = this.CreateGraphics();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
for (i=1;i==2;i++)
{
g.DrawImageUnscaled(bm,500,500);
}
 
What is it that you're trying to achieve here? Maybe your form is smaller
than 500x500?

vJ
 
John said:
How can I draw any thing within "for" loop? I tried the
below but it doesn't draw anything. What should I do?

****
Code
****

Graphics g = this.CreateGraphics();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
for (i=1;i==2;i++)
{
g.DrawImageUnscaled(bm,500,500);
}

This has nothing to do with drawing - your for loop is misconstructed.
It sets i to 1, then only continues while i is 2. As it clearly isn't 2
to start with, the body never gets executed.
 
John said:
How can I draw any thing within "for" loop? I tried the
below but it doesn't draw anything. What should I do?

****
Code
****

Graphics g = this.CreateGraphics();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
for (i=1;i==2;i++)
{
g.DrawImageUnscaled(bm,500,500);
}

g.DrawImageUnscaled(bm,500,500) never gets executed. I assume you were
trying to draw a pixel...
 
Back
Top