Delete a port of a predefined shape that was created with shape factory

Applies to: Nevron Diagram for .NET

How to delete a port of a predefined shape that was created with shape factory?

If you need to remove a port from a predefined shape, you can remove it from the Ports collection of the shape. The following code example shows how to remove the center port of a rectangle shape:

[C#]
// create the basic shapes factory
NBasicShapesFactory factory = new NBasicShapesFactory(nDrawingDocument1);
  
// create a rectangle and remove the center port
NShape rect1 = factory.CreateShape(BasicShapes.Rectangle);
NPort port1 = (NPort)rect1.Ports.GetChildByName("Center");
rect1.Ports.RemoveChild(port1);
nDrawingDocument1.ActiveLayer.AddChild(rect1);

[VB.NET]
' create the basic shapes factory
Dim factory As New NBasicShapesFactory(nDrawingDocument1)
  
' create a rectangle and remove the center port
Dim rect1 As NShape = factory.CreateShape(BasicShapes.Rectangle)
Dim port1 As NPort = DirectCast(rect1.Ports.GetChildByName("Center"), NPort)
rect1.Ports.RemoveChild(port1)
nDrawingDocument1.ActiveLayer.AddChild(rect1)

Article ID: 77, Created On: 10/6/2010, Modified: 11/15/2010