使用文本框

在 Aspose.Words 中,TextBox 类用于指定文本在形状内的显示方式。它公开一个名为 Parent 的公共属性来获取文本框的父形状,以便客户可以从关联的 TextBox 中找到链接的 Shape

创建链接

TextBox 类提供了 IsValidLinkTarget 方法来检查 TextBox 是否可以链接到目标 Textbox

以下代码示例显示如何检查 TextBox 是否可以链接到目标文本框:

检查文本框顺序

有多种方法可以在形状中显示文本。 TextBox 可以是序列的头部、中间或尾部。

以下代码示例显示如何检查 TextBox 是序列的头、尾还是中间:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document();
Shape shape = new Shape(doc, ShapeType.TextBox);
TextBox textBox = shape.TextBox;
if ((textBox.Next != null) && (textBox.Previous == null))
{
Console.WriteLine("The head of the sequence");
}
if ((textBox.Next != null) && (textBox.Previous != null))
{
Console.WriteLine("The Middle of the sequence.");
}
if ((textBox.Next == null) && (textBox.Previous != null))
{
Console.WriteLine("The Tail of the sequence.");
}

断开链接

使用 BreakForwardLink 方法,您可以断开到下一个 TextBox 的链接。

以下代码示例显示如何断开 TextBox 的链接: