使用TextBoxes

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

创建链接

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

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

检查TextBox序列

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

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

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
System::SharedPtr<Document> doc = System::MakeObject<Document>();
System::SharedPtr<Shape> shape = System::MakeObject<Shape>(doc, ShapeType::TextBox);
System::SharedPtr<TextBox> textBox = shape->get_TextBox();
if ((textBox->get_Next() != nullptr) && (textBox->get_Previous() == nullptr))
{
std::cout << "The head of the sequence" << std::endl;
}
if ((textBox->get_Next() != nullptr) && (textBox->get_Previous() != nullptr))
{
std::cout << "The Middle of the sequence." << std::endl;
}
if ((textBox->get_Next() == nullptr) && (textBox->get_Previous() != nullptr))
{
std::cout << "The Tail of the sequence." << std::endl;
}

断开链接

使用BreakForwardLink方法可以断开指向下一个TextBox的链接。

下面的代码示例演示如何断开TextBox的链接: