Create a cust usercontrol project, insert the following codes to that calass. This is only a very simple example to make you go ahead.-----------------------------------------------public override void OnPaint(PaintEventArgs e)
{
Pen p = new Pen(Color.Blue);p.StartCap = System.Drawing.Drawing2D.LineCap.Square;
p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
p.Width = 5;
e.Graphics.DrawLine(p,100,100,340,240);}
■■■■■ To teach a fish how to swim. ■■■■■
{
Pen p = new Pen(Color.Blue);p.StartCap = System.Drawing.Drawing2D.LineCap.Square;
p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
p.Width = 5;
e.Graphics.DrawLine(p,100,100,340,240);}
■■■■■ To teach a fish how to swim. ■■■■■
I'am trying
I test the code but it does not what I want
The above code draw a fix arrow line in the rectangle but what I want is :the whole control is just a arrow line I can change it's direction
by set it's start and end point property
--------------------------------------------
1. Define 2 private variables:
private Point _start;
private Point _endPoint;2. Give the default value for the two variables in the constructor of the class user control_startPoint = new Point(1,1);
_endPoint = new Point(100,100);3.Define a property of the class.
public Point StartPoint
{
set
{
_startPoint = value;
}
get
{
return _startPoint;
}
}4. change the line "e.Graphics.DrawLine(p,100,100,340,240);" to "
e.Graphics.DrawLine(p,_startPoint,_endPoint);"5. Build you control again. 6. Then you can change the StartPoint property from the "property window" now. If you want to change other property, such as end pont,color, you can go ahead form here by yourself.Any problem or comments, please feel free to let me know.■■■■■ To teach a fish how to swim. ■■■■■
congratulations on your promotion and I'am very appreciate for your helpI'am very sorry that I'am not make myself very clear My problems is 1.I want my control's shape to be an arrow line not a rectangle
(I have no idea about this point!)2.I need some hot point on the line's inflexion when user click it
by mouse the control can show the hot point so User can adjust it to a curve by mouse Am I clear now ?!
TheAres:
I'll try very means to take it ,I'll send my solutions to u
:D and take u a fresh fish
{
this._endPoint = new Point(e.X,e.Y);
this.Refresh();}■■■■■ To teach a fish how to swim. ■■■■■
actually I do the the same Project as u did
could u give me some good opinions about your UserControl
It is my grestest honor to learn more about from u