Back to Devexpress

ShapeCollection.AddConnector(ConnectorType, Single, Single, Single, Single) Method

officefileapi-devexpress-dot-spreadsheet-dot-shapecollection-dot-addconnector-x28-devexpress-dot-spreadsheet-dot-connectortype-system-dot-single-system-dot-single-system-dot-single-system-dot-single-x29.md

latest7.2 KB
Original Source

ShapeCollection.AddConnector(ConnectorType, Single, Single, Single, Single) Method

Creates an unbound shape connector.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Shape AddConnector(
    ConnectorType connectorType,
    float startX,
    float startY,
    float endX,
    float endY
)
vb
Function AddConnector(
    connectorType As ConnectorType,
    startX As Single,
    startY As Single,
    endX As Single,
    endY As Single
) As Shape

Parameters

NameTypeDescription
connectorTypeConnectorType

One of the ConnectorType enumeration values indicating the connector’s type.

| | startX | Single |

A Single value indicating the starting point’s distance from the left of the worksheet.

| | startY | Single |

A Single value indicating the staring point’s distance from the top of the worksheet.

| | endX | Single |

A Single value indicating the end point’s distance from the left of the worksheet.

| | endY | Single |

A Single value indicating the end point’s distance from the top of the worksheet.

|

Returns

TypeDescription
Shape

A Shape object that is the resulting shape connector.

|

Remarks

Note

The ISpreadsheetComponent.Unit property determines the units of linear dimensions (startX, startY, endX, endY).

The Shape.ShapeType property allows you to determine a drawing object’s type in the ShapeCollection collection.

Use the ConnectorFormat.ConnectorType to change the connector’s type. Change the connector’s color using the ShapeFormatBase.Outline property.

The ConnectorFormat.Arrows property provides access to the connector’s arrows properties. You can specify the arrowhead’s type (ArrowSettings.StartArrowheadType or ArrowSettings.EndArrowheadType) and size (ArrowSettings.StartArrowheadLength, ArrowSettings.StartArrowheadWidth and ArrowSettings.EndArrowheadLength, ArrowSettings.EndArrowheadWidth).

You can bind the connector to shapes. Use the ConnectorFormat.ConnectStartPoint and ConnectorFormat.ConnectEndPoint methods to complete the task. Determine the shape’s connection site amount using the ShapeGeometry.ConnectionSiteCount property. The ConnectorFormat.EndPointConnected and ConnectorFormat.StartPointConnected properties indicate whether the connector is already bound to shapes.

Example

The code sample below shows how to insert a shape connector, provide it with arrows, change the outline color and attach it to shapes. Both ends are connected to the third connection site of each shape.

csharp
// Insert a shape connector.
Shape shapeConnector = worksheet.Shapes.AddConnector(ConnectorType.Curved, 10, 10, 100, 100);
// Adjust the connector's outline.
shapeConnector.Outline.SetSolidFill(Color.Black);
shapeConnector.Outline.Width = 2.5;

// Convert the connector's ends into arrows.
ConnectorFormat connectorFormat = shapeConnector.ConnectorFormat;
connectorFormat.Arrows.StartArrowheadType = ArrowheadType.Stealth;
connectorFormat.Arrows.StartArrowheadWidth = ArrowheadSize.Large;
connectorFormat.Arrows.StartArrowheadLength = ArrowheadSize.Large;

connectorFormat.Arrows.EndArrowheadType = ArrowheadType.Stealth;
connectorFormat.Arrows.EndArrowheadWidth = ArrowheadSize.Large;
connectorFormat.Arrows.EndArrowheadLength = ArrowheadSize.Large;

// Bind the connector to two shapes.
connectorFormat.ConnectStartPoint(shape1, 3);
connectorFormat.ConnectEndPoint(shape2, 3);
vb
' Insert a shape connector.
Dim shapeConnector As Shape = worksheet.Shapes.AddConnector(ConnectorType.Curved, 10, 10, 100, 100)
' Adjust the connector's outline.
shapeConnector.Outline.SetSolidFill(Color.Black)
shapeConnector.Outline.Width = 2.5

' Convert the connector's ends into arrows.
Dim connectorFormat As ConnectorFormat = shapeConnector.ConnectorFormat
connectorFormat.Arrows.StartArrowheadType = ArrowheadType.Stealth
connectorFormat.Arrows.StartArrowheadWidth = ArrowheadSize.Large
connectorFormat.Arrows.StartArrowheadLength = ArrowheadSize.Large

connectorFormat.Arrows.EndArrowheadType = ArrowheadType.Stealth
connectorFormat.Arrows.EndArrowheadWidth = ArrowheadSize.Large
connectorFormat.Arrows.EndArrowheadLength = ArrowheadSize.Large

' Bind the connector to two shapes.
connectorFormat.ConnectStartPoint(shape1, 3)
connectorFormat.ConnectEndPoint(shape2, 3)

See Also

ShapeCollection Interface

ShapeCollection Members

DevExpress.Spreadsheet Namespace