TX Text Control .NET for WPF

GetItem Method

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

Description

Gets a particular table of contents from the collection.

Syntax

GetItem()

Gets the table of contents at the current text input position. If there is no table of contents, null is returned.

public TableOfContents GetItem();

GetItem(string)

Gets the table of contents with the specified name. The method returns null, if such a table of contents does not exist. If more than one table of contents with this name exists, the first found table of contents is returned.

public TableOfContents GetItem(string name);
ParameterDescription
name

Specifies the name set with the Name property. The method returns null if a table of contents with the specified name does not exist.

GetItem(int)

Gets the table of contents with the specified id. The method returns null, if such a table of contents does not exist. If more than one table of contents with this id exists, the first found table of contents is returned.

public TableOfContents GetItem(int id);
ParameterDescription
id

Specifies the identifier of the table of contents. The method returns null if a table of contents with the specified identifier does not exist.

Return Value

The return value is null, if a table of contents with the specified parameters could not be found. Otherwise, it is an object of the type TableOfContents.

Examples

The following example works with tables of contents in the current document by using TableOfContentsCollection.get_Item.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
TableOfContentsCollection tableOfContentsCollection = textControl.TablesOfContents;
tableOfContentsCollection.Add(new TableOfContents(1, 3) { Name = "Contents", ID = 100 });

TableOfContents result = tableOfContentsCollection.GetItem(100);
result?.ScrollTo();