Drawing Line over Form and labels

I write ProgramTic Tac Toe. Can u tell me how i may draw line over form and labels?
[code]
public partial class Form1 : Form
{

Label[] X_0 = new Label[9];
bool[] position = new bool[9];

public Form1()
{
InitializeComponent();
int x = 15, y = 15;

for (int i = 0; i < 9; i++)
{
X_0[i] = new Label();
X_0[i].Location = new Point(x, y);
X_0[i].Size = new Size(60, 60);
X_0[i].Text = "";
X_0[i].AutoSize = false;
X_0[i].BorderStyle = BorderStyle.Fixed3D;
X_0[i].BackColor = Color.Yellow;
X_0[i].Font = new Font("Arial", 40F);
X_0[i].TextAlign = ContentAlignment.MiddleCenter;
X_0[i].Tag = i;
X_0[i].Click += new System.EventHandler(Button_Click);
Controls.Add(X_0[i]);
x += 75;
if (i == 2 || i==5) { x = 15; y += 75; }
position[i] = false;
}


}

int q=0;
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Graphics gr = e.Graphics;
Pen myPen = new Pen(Color.Red, 3);
Point one = new Point(40, 15);
Point two = new Point(40, 200);
gr.DrawLine(myPen, one, two);
}

void Button_Click(object sender, EventArgs e)
{
Label lclick = (Label)sender;
int n = Convert.ToInt32(lclick.Tag);
Random x = new Random();
bool downl = true;

if (!position[n])
{
X_0[n].Text = "X";
position[n] = true;
if (q != 4)
{
while (downl)
{
int y = x.Next(0, 9);
if (!position[y])
{
X_0[y].Text = "0";
position[y] = true;
downl = false;
q++;
}
}
}
}

}
}

[/code]

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion