Bekerja dengan TextBoxes
Dalam Aspose.Words, kelas TextBox digunakan untuk menentukan bagaimana teks ditampilkan di dalam bentuk. Ini memperlihatkan properti publik bernama Parent untuk mendapatkan bentuk induk untuk kotak teks sehingga pelanggan dapat menemukan Shape tertaut dari TextBox terkait.
Buat Tautan
Kelas TextBox menyediakan metode IsValidLinkTarget untuk memeriksa apakah TextBox dapat ditautkan ke target Textbox.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox
dapat ditautkan ke Kotak Teks target:
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> shape1 = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<Shape> shape2 = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<TextBox> textBox1 = shape1->get_TextBox(); | |
System::SharedPtr<TextBox> textBox2 = shape2->get_TextBox(); | |
if (textBox1->IsValidLinkTarget(textBox2)) | |
{ | |
textBox1->set_Next(textBox2); | |
} |
Periksa Urutan TextBox
Ada beberapa cara untuk menampilkan teks dalam bentuk. TextBox dapat berupa Kepala, Tengah, atau Ekor dari suatu barisan.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox adalah Kepala, Ekor, atau Bagian Tengah urutan:
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; | |
} |
Putuskan Tautan
Dengan menggunakan metode BreakForwardLink, Anda dapat memutuskan tautan ke TextBox berikutnya.
Contoh kode berikut menunjukkan cara memutuskan tautan untuk 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(); | |
// Break a forward link | |
textBox->BreakForwardLink(); | |
// Break a forward link by setting a null | |
textBox->set_Next(nullptr); | |
// Break a link, which leads to this textbox | |
if (textBox->get_Previous() != nullptr) | |
{ | |
textBox->get_Previous()->BreakForwardLink(); | |
} |