Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,I want draw a line dynamically between two label,how can I do it?
I don't want use graphic methods, I want do it with windows form toolbox (CLR) , but I don'n know how.
this line just is a straight line that connect two node ( here a label ) of a binary tree.
Posted

1 solution

You can't - you really need to draw this using graphics methods, preferably in the Paint event handler for the form or a container such as a Panel.

There is no standard control which just draws a line and which "follows" your controls as they potentially move around.
 
Share this answer
 
Comments
TheCaptain10 24-Jul-15 12:20pm    
Thanks,but I don't know how do that!
Can you give me an example?
For example draw a line between two points (10,10) and (30,30).
OriginalGriff 24-Jul-15 12:37pm    
Depends what language you use, but...
Handle the Paint event for a panel (or a form) and use the supplied graphics context:
e.Graphics.DrawLine(Pens.Red, 10, 10, 30, 30);
If you look at the examples in the MSDN documentation it'll help:
https://msdn.microsoft.com/en-us/library/xckcwxsa(v=vs.110).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900