TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Charles Morissette
NA
29
42.8k
Adding a multitude of lines
Apr 11 2011 3:03 PM
Right now I'm trying to draw a printable form - I have the print working properly right now but I need to get lines to be drawn on the form. Right now I'm using a button with
[code]
private void button1_Click_1(object sender, EventArgs e)
{
int BiggestSize = 100;
panel5.Paint += new PaintEventHandler(LinePainter);
Value1 = 1;
Value2 = BiggestSize;
Value3 = panel5.Width;
Value4 = BiggestSize;
}
[/code]
[code]
private void LinePainter(object sender, PaintEventArgs Painte)
{
Pen ColourPen = new Pen(System.Drawing.Color.Red);
int ColourPosition = 1;
if (Company == "MCI")
{
switch(ColourPosition)
{
case 1:
ColourPen.Color = (System.Drawing.Color.MediumSlateBlue);
ColourPosition = 2;
break;
case 2:
ColourPen.Color = (System.Drawing.Color.DarkOliveGreen);
ColourPosition = 3;
break;
case 3:
ColourPen.Color = (System.Drawing.Color.DarkOrange);
ColourPosition = 1;
break;
}
}
else if (Company == "SteelWorks")
{
switch (ColourPosition)
{
case 1:
ColourPen = new Pen(System.Drawing.Color.MediumSlateBlue);
ColourPosition = 2;
break;
case 2:
ColourPen = new Pen(System.Drawing.Color.MediumSlateBlue);
ColourPosition = 3;
break;
case 3:
ColourPen = new Pen(System.Drawing.Color.MediumSlateBlue);
ColourPosition = 1;
break;
}
}
System.Drawing.Graphics graphicsOBJ;
graphicsOBJ = this.panel5.CreateGraphics();
graphicsOBJ.DrawLine(ColourPen, new Point(Value1, Value2),new Point(Value3, Value4));
//Painte.Graphics.DrawLine(ColourPen, V1, V2, V3, V4);
//Painte.Dispose();
label1.Text = ColourPosition.ToString();
}
[/code]
I can't get the switch to work as well, but that seems to be because the eventhandler throws itself as always on (if I change the label1.text in my code, it changes on the form without me pressing the button).
I've tried to find out how to turn this into an instanced version of a drawing creation but can't quite get the right info on it. Any help?
My end goal is to draw a line as many time as is required by the user - in this case, when they press button1.
Reply
Answers (
5
)
powerpoint
how to copy data tiff file into Doc using c#