Newbie question... simple app.

  • Thread starter Thread starter James Gockel
  • Start date Start date
J

James Gockel

Making a very simple application, I used to program in VB, and C# is
similar, but very different in its own ways.
Trying to figure out how to call

Private void DrawGameboard()
{
/: Draws rectangles here :/
}

When the form has loaded, so it'll draw the rectangles..

I try to impliment somthing like

private void Form1_Load(object sender, EventArgs e)
{
drawgameboard();
}


Basically I'm learning, and I'm a little confused. I'm trying to write a
tictactoe game from scratch.
I can't even draw the gameboard...

I've tried looking it up, but I can't find anything about how form_load
works, or how I can create other "handlers"?
Trying to use VC# Express.

Many Thanks...
-James
 
You need a surface to draw on, the easiest way is to add your code to the
OnPaint routine, e.g.

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
Graphics g =e.Graphics;
g.DrawLine(new Pen(Color.Black),0,
this.ClientRectangle.Height/3,this.ClientRectangle.Width,this.ClientRectangle.Height/3);
g.DrawLine(new Pen(Color.Black),0,
2*this.ClientRectangle.Height/3,this.ClientRectangle.Width,2*this.ClientRectangle.Height/3);
g.DrawLine(new Pen(Color.Black),
this.ClientRectangle.Width/3,0,this.ClientRectangle.Width/3,this.ClientRectangle.Height);
g.DrawLine(new Pen(Color.Black),
2*this.ClientRectangle.Width/3,0,2*this.ClientRectangle.Width/3,this.ClientRectangle.Height);
}

Also if you want it to look right when the form is resized, add

private void Form1_Resize(object sender, System.EventArgs e)
{
this.Invalidate();
}
 
Great!
But Maybe I should also add an extra question...
How do I find out what all these extra hidden routines are?

Or is it just not showing them in VC# Express Beta....
I'm sure I need to just scrounge the cash up for Visual Studio... but yeah..
-James
 
James said:
Great!
But Maybe I should also add an extra question...
How do I find out what all these extra hidden routines are?

Or is it just not showing them in VC# Express Beta....
I'm sure I need to just scrounge the cash up for Visual Studio... but yeah..
-James
you can use the msdn on the net:
http://msdn.microsoft.com/library/
and the editor/compilator 'dev c++'
http://www.bloodshed.net/devcpp.html

nothing to pay
 
Back
Top