-
March 5th, 2014, 04:49 AM
#1
Please help doing c# homework
Please can u show me the way how to make three line in different directions using c# windows form with three buttons.I made it the code but lines are in same directions.Thnx
Code:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ThreeLines
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Pen lapsi;
lapsi = new Pen(Color.Red);
Graphics grafika = this.CreateGraphics();
grafika.DrawLine(lapsi, 0, 0, 100, 100);
}
private void button2_Click(object sender, EventArgs e)
{
Pen pen;
pen = new Pen(Color.Black);
Graphics grafika2 = this.CreateGraphics();
grafika2.DrawLine(pen, 200, 200, 300, 300);
}
private void button3_Click(object sender, EventArgs e)
{
Pen pencil;
pencil = new Pen(Color.Blue);
Graphics grafika3 = this.CreateGraphics();
grafika3.DrawLine(pencil, 400, 400, 500, 500);
}
}
}
Last edited by HanneSThEGreaT; March 8th, 2014 at 02:45 AM.
Reason: added code tags
-
March 5th, 2014, 12:17 PM
#2
Re: Please help doing c# homework
Change the values you are using. Instead of using 0,0,100,100, try 0,0, 35, 500 and see what happens. Don't be afraid to experiment.
-
March 5th, 2014, 01:13 PM
#3
Re: Please help doing c# homework
Arjay. thank you it worked.I made it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|