2

I am trying to create a control in .NET that shows two lists with items where users can connect them using drag&drop, and lines are drawn showing the connections. This control can serve several purposes (mapping two lists, connecting questions and answers, building relationships, etc.).

The idea is that the lines can be added and deleted in an easy way. Not sure if I should use straight lines or curved ones, since with curved ones maybe it would be harder to spot the connections if all of the items are connected.

I know that this would be a pain to do using WinForms, plus I won't have the flexibility of upgrading the looks of the control. I think I should be going the WPF way, but not sure how to approach the solution. Any help with an example would be greatly appreciated.

Here is a rough sketch of what I am intending to create. Of course once the control is working I need to work on giving it better looks.

nachocho
  • 53
  • 4
  • possible duplicate of [How to Draw line/s between Two DataGridView Controls](http://stackoverflow.com/questions/16061001/how-to-draw-line-s-between-two-datagridview-controls) – Federico Berasategui Oct 15 '14 at 05:22
  • Thanks @HighCore, that example is really useful! I was browsing your answers and stumbled upon this other control [How to create and connect custom user buttons/controls with lines using windows forms](http://stackoverflow.com/questions/15819318/how-to-create-and-connect-custom-user-buttons-controls-with-lines-using-windows), but the source code link does not work. I think I can benefit as well from that sample. Could you edit that answer or send me a working link to that sample? Thanks a lot – nachocho Oct 16 '14 at 14:34
  • I just edited that answer and uploaded the source to GitHub. Enjoy ;) – Federico Berasategui Oct 16 '14 at 16:09

1 Answers1

0

Agree with HighCore - take a look at the Canvas in WPF. You can also do this in WinForms using GDI+. Basically, you need to define your endpoints - could be by click, or by border of the listItem. Then, you store a collection of lines that link them. When your listItems change position, you need to adjust the line on the canvas.