TX Text Control .NET for Windows Forms

Add Method

Method|Introduced in 23.0
Namespace
TXTextControl.DataVisualization
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Inserts a new drawing in a Text Control document.

Syntax

Add(DrawingFrame, int)

Inserts a drawing inline, which means that it is treated in the text like a single character.

public bool Add(DrawingFrame drawingFrame, int textPosition);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

textPosition

Specifies the text position at which the drawing is to be inserted. If -1 is specified, the drawing is inserted at the current input position.

Add(DrawingFrame, HorizontalAlignment, int, FrameInsertionMode)

Inserts a drawing, which is anchored to the specified text position. It has the specified horizontal alignment relative to the paragraph into which it is inserted and the textflow is given through the insertionMode parameter. An anchored drawing is moved with the text. FrameInsertionMode.FixedOnPage and FrameInsertionMode.AsCharacter cannot be specified with this overload.

public bool Add(DrawingFrame drawingFrame, HorizontalAlignment alignment, int textPosition, FrameInsertionMode insertionMode);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

alignment

Specifies the drawing's horizontal alignment. It can be one of the HorizontalAlignment values:

ValueMeaning
LeftThe drawing is left aligned, relative to the paragraph to which it is anchored.
RightThe drawing is right aligned, relative to the paragraph to which it is anchored.
CenteredThe drawing is centered, relative to the paragraph to which it is anchored.
JustifyThis value is not supported for the alignment of drawings.
textPosition

Specifies the text position at which the drawing is to be inserted. If -1 is specified, the drawing is inserted at the current input position.

insertionMode

Specifies how the text flow is handled. It can be one of the values of the FrameInsertionMode enumeration.

Add(DrawingFrame, Point, int, FrameInsertionMode)

Inserts a drawing, which is anchored to the specified text position. The specified location is relative to the paragraph into which it is inserted and the textflow is given through the insertionMode parameter. An anchored drawing is moved with the text. FrameInsertionMode.FixedOnPage and FrameInsertionMode.AsCharacter cannot be specified with this overload.

public bool Add(DrawingFrame drawingFrame, Point location, int textPosition, FrameInsertionMode insertionMode);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

location

Specifies the location, in twips, at which the drawing is to be inserted.

textPosition

Specifies the text position at which the drawing is to be inserted. If -1 is specified, the drawing is inserted at the current input position.

insertionMode

Specifies how the text flow is handled. It can be one of the values of the FrameInsertionMode enumeration.

Add(DrawingFrame, int, Point, FrameInsertionMode)

Inserts a drawing, which has a fixed geometrical position in the document. This position is specified through a page number and a location on this page and the textflow is given through the insertionMode parameter. FrameInsertionMode.MoveWithText and FrameInsertionMode.AsCharacter cannot be specified with this overload.

public bool Add(DrawingFrame drawingFrame, int pageNumber, Point location, FrameInsertionMode insertionMode);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

pageNumber

Specifies the number of a page beginning with 1 where the drawing is located.

location

Specifies the location, in twips, at which the drawing is to be inserted.

insertionMode

Specifies how the text flow is handled. It can be one of the values of the FrameInsertionMode enumeration.

Add(DrawingFrame, Point, FrameInsertionMode)

Inserts a drawing, which has a fixed geometrical position in the document. This position is specified relative to the complete document and the textflow is given through the insertionMode parameter. FrameInsertionMode.MoveWithText and FrameInsertionMode.AsCharacter cannot be specified with this overload.

public bool Add(DrawingFrame drawingFrame, Point location, FrameInsertionMode insertionMode);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

location

Specifies the location, in twips, at which the drawing is to be inserted.

insertionMode

Specifies how the text flow is handled. It can be one of the values of the FrameInsertionMode enumeration.

Add(DrawingFrame, FrameInsertionMode)

Inserts a drawing with the built-in mouse interface. The drawing's size is determined through the end-user. A cross cursor indicates where the drawing can be inserted. Changing the document or pressing the ESC key aborts the insertion process.

public bool Add(DrawingFrame drawingFrame, FrameInsertionMode insertionMode);
ParameterDescription
drawingFrame

Specifies the drawing and its frame to add.

insertionMode

Specifies how the text flow is handled. It can be one of the values of the FrameInsertionMode enumeration.

Return Value

The return value is true, if the drawing could be added. Otherwise, it is false.

Examples

The following example adds an item to the drawing collection.

if (!drawingCollection.Add(new TXTextControl.DataVisualization.DrawingFrame("Approved"), -1))
{
    throw new InvalidOperationException("The item could not be inserted.");
}

Further Reading