Creating Steps using loops

Stained_Silva

New member
Joined
Jan 23, 2015
Messages
4
Programming Experience
Beginner
Hi Guys,

I Just learnt how to do loops, but very basic ones..
I have this question I am battling with now.

I need to create some steps, using drawings of squares. Basically it starts with one block and then moves down to 2 blocks etc etc until there's a line with 6 blocks across, 6 blocks down.
I only manage to make the first block and then the program sits there, it doesn't make any further blocks. : / Any help would be grand!

Here's what I have :

namespace Question_2_Ex_8._4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void pictureBox1_Click(object sender, EventArgs e)
{
int x;
int y;


Graphics paper;
paper = pictureBox1.CreateGraphics();
paper.Clear(Color.White);
Pen myPen = new Pen(Color.Black);


x = 10;
y = 10;
for (int step = 1; step <= 6; step++)
{
paper.DrawRectangle(myPen, x, y, 10, 10);
}
y = y + 15;
x = x + 15;


}
}
}
 
It sounds as you need nested loops, one loop for lines, and within one loop for steps.

Also, do use the Paint event for drawing, and do use the provided e.Graphics. Do not use CreateGraphics for drawing.
 
Thanks John for the speedy reply, ok I see the need for nested loops now.. unfortunately my textbook has only shown me how to use CreateGraphics.. I have no idea what e.Graphics etc is..
 
Back
Top Bottom