Previous
内容
[
隐藏
]TextBox.Previous property
返回一个TextBox
代表之前的TextBox
以一系列形状.
public TextBox Previous { get; }
例子
展示如何链接文本框。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape textBoxShape1 = builder.InsertShape(ShapeType.TextBox, 100, 100);
TextBox textBox1 = textBoxShape1.TextBox;
builder.Writeln();
Shape textBoxShape2 = builder.InsertShape(ShapeType.TextBox, 100, 100);
TextBox textBox2 = textBoxShape2.TextBox;
builder.Writeln();
Shape textBoxShape3 = builder.InsertShape(ShapeType.TextBox, 100, 100);
TextBox textBox3 = textBoxShape3.TextBox;
builder.Writeln();
Shape textBoxShape4 = builder.InsertShape(ShapeType.TextBox, 100, 100);
TextBox textBox4 = textBoxShape4.TextBox;
// 在一些文本框之间创建链接。
if (textBox1.IsValidLinkTarget(textBox2))
textBox1.Next = textBox2;
if (textBox2.IsValidLinkTarget(textBox3))
textBox2.Next = textBox3;
// 只有空文本框才可以有链接。
Assert.True(textBox3.IsValidLinkTarget(textBox4));
builder.MoveTo(textBoxShape4.LastParagraph);
builder.Write("Hello world!");
Assert.False(textBox3.IsValidLinkTarget(textBox4));
if (textBox1.Next != null && textBox1.Previous == null)
Console.WriteLine("This TextBox is the head of the sequence");
if (textBox2.Next != null && textBox2.Previous != null)
Console.WriteLine("This TextBox is the middle of the sequence");
if (textBox3.Next == null && textBox3.Previous != null)
{
Console.WriteLine("This TextBox is the tail of the sequence");
// 断开textBox2和textBox3之间的前向链接,然后验证它们不再链接。
textBox3.Previous.BreakForwardLink();
Assert.IsTrue(textBox2.Next == null);
Assert.IsTrue(textBox3.Previous == null);
}
doc.Save(ArtifactsDir + "Shape.CreateLinkBetweenTextBoxes.docx");
也可以看看
- class TextBox
- 命名空间 Aspose.Words.Drawing
- 部件 Aspose.Words