This project is read-only.

How do i create more than one line/link/connector between two shapes?

Jan 3, 2012 at 10:25 AM

I would like to know how I can create more than one line between two shapes?


Shape shape1= new Shape();
Shape shape2= new Shape();

Connector con1= new Connector(shape1,shape2);

Connector con2= new Connector(shape1,shape2);

problem is I can not see two lines,Does any one have an idea on how I can get over this?

Thanks in Advance

Jan 3, 2012 at 1:17 PM
Edited Jan 3, 2012 at 1:17 PM

You need to use 'Ports' . A port defines where a line docks onto the shape. You will see a ports collection inside the Shape. You can set its location or its orientation (eg Top/Bottom/Left/Right) 

You then connect the lines to the port instead of the shape.

Jan 3, 2012 at 1:59 PM

Thank you so much.

I had thought of something like that and i even did use it

 private Model TestTwoLine()
            Model model = new Model();

            Table table = new Table();

            //Set Element properties
            table.Location = new PointF(100, 50);
            table.Width = 140;
            table.Height = 200;
            table.Indent = 10;
            table.Heading = "Element";
            table.SubHeading = "Class";
            table.DrawExpand = true;

            model.Shapes.Add("TestTable1", table);

            Table table2 = new Table();
            table2.Location = new PointF(500, 100);
            table2.Width = 140;
            table2.Height = 200;
            table2.Indent = 10;
            table2.Heading = "Element";
            table2.SubHeading = "Class";
            table2.DrawExpand = true;
            Port p1 = new Port(PortOrientation.Top);
            Port p2 = new Port(PortOrientation.Right);
            Port p3 = new Port(PortOrientation.Left);
            Port p4 = new Port(PortOrientation.Bottom);

            Connector con1 = new Connector(p1,p3);

            con1.Avoid = true;
            Link con2 = new Connector(p2,p4);
            model.Shapes.Add("TestTable2", table2);
            return model;

But I anticipated some limitation;

1. what if I want to  create more than four connections between two shapes?

2.If i want to create a link/connection from a shape's top port to that same shape's bottom port the line is hidden behind or drawn within the shape.

But if this is the only way to do it then I guess i will have to work with that.

Thank you again

Jan 3, 2012 at 2:04 PM

A port also has a percentage along the top/bottom/left/right (default 50%) - so you can place multiple ports along one side.

Jan 3, 2012 at 3:35 PM

Thank you very much.

I would also like to ask how can I make a line that run for one port to another port of the same shape e.g

top port and bottom port

I created one but it cant avoid the shape so it is either drawn behind or infront.


Jan 3, 2012 at 3:36 PM

You need to use a connector, it will route around the shape by itself.

Jan 3, 2012 at 3:41 PM
jameswestgate wrote:

You need to use a connector, it will route around the shape by itself.

I did that but was not looking so good- but now that you told me about the percentages then i think if i create ports using percentages that that would look better.Thank you.