Back to Devexpress

ShapeCollection.AddTextBox(Single, Single, Single, Single, String) Method

officefileapi-devexpress-dot-spreadsheet-dot-shapecollection-dot-addtextbox-x28-system-dot-single-system-dot-single-system-dot-single-system-dot-single-system-dot-string-x29.md

latest4.4 KB
Original Source

ShapeCollection.AddTextBox(Single, Single, Single, Single, String) Method

Inserts a text box.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Shape AddTextBox(
    float x,
    float y,
    float width,
    float height,
    string text
)
vb
Function AddTextBox(
    x As Single,
    y As Single,
    width As Single,
    height As Single,
    text As String
) As Shape

Parameters

NameTypeDescription
xSingle

A Single value indicating the distance from the left of the worksheet.

| | y | Single |

A Single value indicating the distance from the top of the worksheet.

| | width | Single |

A Single value that is the text box’s width.

| | height | Single |

A Singlevalue that is the text box’s height.

| | text | String |

A string value that is the text box’s content.

|

Returns

TypeDescription
Shape

A Shape object that is the resulting text box.

|

Remarks

Note

The ISpreadsheetComponent.Unit property determines the units of linear dimensions (x, y, width, height).

The following properties help you determine whether the current Shape object is a text box:

Change the text box’s fill and outline settings using the ShapeFormatBase.Fill and ShapeFormatBase.Outline properties.

Use the Shape.ShapeText property to access the shape’s text options.

The Shape.Rotation property allows you to define the text box’s rotation angle.

Delete the text box using the ShapeCollection.RemoveAt or Shape.Delete method.

Example

The code sample below shows how to insert, rotate and color a text box:

csharp
Shape textBox = worksheet.Shapes.AddTextBox(50, 120, 500, 100, "Spreadsheet");
textBox.Fill.SetSolidFill(Color.PowderBlue);
textBox.Rotation = 30;
vb
Dim textBox As Shape = worksheet.Shapes.AddTextBox(50, 120, 500, 100, "Spreadsheet")
textBox.Fill.SetSolidFill(Color.PowderBlue)
textBox.Rotation = 30

See Also

ShapeCollection Interface

ShapeCollection Members

DevExpress.Spreadsheet Namespace