کار با TextBoxها
در Aspose.Words، کلاس TextBox برای تعیین نحوه نمایش متن در یک شکل استفاده می شود. این یک ویژگی عمومی به نام Parent را برای دریافت شکل والد برای جعبه متن نمایش می دهد تا مشتری بتواند Shape پیوند شده را از TextBox مرتبط پیدا کند.
ایجاد لینک
کلاس TextBox روش IsValidLinkTarget را به منظور بررسی اینکه آیا 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 shape1 = new Shape(doc, ShapeType.TextBox); | |
Shape shape2 = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox1 = shape1.TextBox; | |
TextBox textBox2 = shape2.TextBox; | |
if (textBox1.IsValidLinkTarget(textBox2)) | |
textBox1.Next = textBox2; |
دنباله 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 را نشان می دهد:
// 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; | |
// Break a forward link | |
textBox.BreakForwardLink(); | |
// Break a forward link by setting a null | |
textBox.Next = null; | |
// Break a link, which leads to this textbox | |
if (textBox.Previous != null) | |
textBox.Previous.BreakForwardLink(); |