TX Text Control .NET for Windows Forms

Add Method

Method|Introduced in 18.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 chart in a Text Control document.

Syntax

Add(ChartFrame, int)

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

public bool Add(ChartFrame chartFrame, int textPosition);
ParameterDescription
chartFrame

Specifies the chart and its frame to add.

textPosition

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

Add(ChartFrame, HorizontalAlignment, int, FrameInsertionMode)

Inserts a chart 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 chart is moved with the text.

public bool Add(ChartFrame chartFrame, HorizontalAlignment alignment, int textPosition, FrameInsertionMode insertionMode);
ParameterDescription
chartFrame

Specifies the chart and its frame to add.

alignment

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

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

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

insertionMode

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

ValueMeaning
AboveTheTextThe chart is inserted at a certain geometrical location above the text. This means that the chart overwrites the text.
BelowTheTextThe chart is inserted at a certain geometrical location below the text. This means that the text overwrites the chart.
DisplaceCompleteLinesThe text stops at the top and continues at the bottom of the chart.
DisplaceTextThe text flows around the chart and empty areas at the left and right side are filled.
Other VauesAll other values cannot be used with the ChartCollection.Add method.

Add(ChartFrame, Point, int, FrameInsertionMode)

Inserts a chart 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 chart is moved with the text.

public bool Add(ChartFrame chartFrame, Point location, int textPosition, FrameInsertionMode insertionMode);
ParameterDescription
chartFrame

Specifies the chart and its frame to add.

location

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

textPosition

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

insertionMode

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

ValueMeaning
AboveTheTextThe chart is inserted at a certain geometrical location above the text. This means that the chart overwrites the text.
BelowTheTextThe chart is inserted at a certain geometrical location below the text. This means that the text overwrites the chart.
DisplaceCompleteLinesThe text stops at the top and continues at the bottom of the chart.
DisplaceTextThe text flows around the chart and empty areas at the left and right side are filled.
Other VauesAll other values cannot be used with the ChartCollection.Add method.

Add(ChartFrame, int, Point, FrameInsertionMode)

Inserts a chart 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.

public bool Add(ChartFrame chartFrame, int pageNumber, Point location, FrameInsertionMode insertionMode);
ParameterDescription
chartFrame

Specifies the chart and its frame to add.

pageNumber

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

location

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

insertionMode

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

ValueMeaning
AboveTheTextThe chart is inserted at a certain geometrical location above the text. This means that the chart overwrites the text.
BelowTheTextThe chart is inserted at a certain geometrical location below the text. This means that the text overwrites the chart.
DisplaceCompleteLinesThe text stops at the top and continues at the bottom of the chart.
DisplaceTextThe text flows around the chart and empty areas at the left and right side are filled.
Other VauesAll other values cannot be used with the ChartCollection.Add method.

Add(ChartFrame, Point, FrameInsertionMode)

Inserts a chart 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.

public bool Add(ChartFrame chartFrame, Point location, FrameInsertionMode insertionMode);
ParameterDescription
chartFrame

Specifies the chart and its frame to add.

location

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

insertionMode

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

ValueMeaning
AboveTheTextThe chart is inserted at a certain geometrical location above the text. This means that the chart overwrites the text.
BelowTheTextThe chart is inserted at a certain geometrical location below the text. This means that the text overwrites the chart.
DisplaceCompleteLinesThe text stops at the top and continues at the bottom of the chart.
DisplaceTextThe text flows around the chart and empty areas at the left and right side are filled.
Other VauesAll other values cannot be used with the ChartCollection.Add method.

Return Value

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

Examples

The following example adds an item to the chart collection.

if (!chartCollection.Add(new TXTextControl.DataVisualization.ChartFrame(new System.ComponentModel.Component()), -1))
{
    throw new InvalidOperationException("The item could not be inserted.");
}