How to get lines between two controls?

prem_rajani

Member
Joined
Jul 19, 2005
Messages
22
Location
Coimbatore
Programming Experience
3-5
Hi all,

I would like to know how to add lines at runtime between two controls. Let me explain it to you exactly what this project does.

The form has two panels - left & right panel. During design time itself I add listbox in the right panel. Next step is I drag the item from listbox and drop it in left panel. After mouse is released based on item a user control is created consisting of groupbox & checkedlistbox. So in this way many usercontrols are created in left panel. Now on one of the checkedlistbox mouse down event starting points are marked and on other checkedlistbox mouseup or dragdrop event end point is marked. I'm able to get the lines but not exactly. The problem I'm facing is that how can I retrieve the lines if form loses its focus or it is minimized. Other problem is that if I scroll down through the checkedlistbox the line doesnt move. How do I fix the line with the selecteditem of checkedlistbox. If any one have idea or solution pls do let me know.

Thanking you.

Prem
 
without seeing your code it is hard to say but for your last point...
When you click your checked listbox the mouse pointer will be at the location where you want your line to be, right. So if your using GDI+ then set a couple of variables to hold the location of the end point of the line in your drawline method and use the current mouse position to change the x2,y2 co-ordinates of the end point of the line. With me?
 
Hey I'll send the code in a day or two. In mean time I have used Microsoft Line controls & it works fine. I know without the code its not possible so shall send it very soon. I'll just tell wat Im doing
1) I plot the starting X & Y co-ordinates on click of Listbox.
2) Then on MouseMove I copy the co-ordinates points as well as drag the line.
3) finally on MouseDown I plot the ending X & Y co-ordinates.

But wat happens is that the line gets drawn taking the form as its main part & not the panel part.
 
Back
Top