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
Inserts a text box.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
Shape AddTextBox(
float x,
float y,
float width,
float height,
string text
)
Function AddTextBox(
x As Single,
y As Single,
width As Single,
height As Single,
text As String
) As Shape
| Name | Type | Description |
|---|---|---|
| x | Single |
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.
|
| Type | Description |
|---|---|
| Shape |
A Shape object that is the resulting text box.
|
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.
The code sample below shows how to insert, rotate and color a text box:
Shape textBox = worksheet.Shapes.AddTextBox(50, 120, 500, 100, "Spreadsheet");
textBox.Fill.SetSolidFill(Color.PowderBlue);
textBox.Rotation = 30;
Dim textBox As Shape = worksheet.Shapes.AddTextBox(50, 120, 500, 100, "Spreadsheet")
textBox.Fill.SetSolidFill(Color.PowderBlue)
textBox.Rotation = 30
See Also