TextBox'larla çalışma
Aspose.Words’te TextBox sınıfı, metnin bir şeklin içinde nasıl görüntüleneceğini belirtmek için kullanılır. Müşterinin ilişkili TextBox‘dan bağlantılı Shape‘i bulabilmesi için metin kutusunun ana şeklini almak üzere Parent adlı bir ortak özelliği ortaya çıkarır.
Bağlantı Oluşturma
TextBox sınıfı, TextBox‘in hedef Textbox‘e bağlanıp bağlanamayacağını kontrol etmek için IsValidLinkTarget yöntemini sağlar.
Aşağıdaki kod örneği, TextBox
‘in hedef Metin Kutusuna bağlanıp bağlanamayacağının nasıl kontrol edileceğini gösterir:
// 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 Sırasını Kontrol Edin
Metni bir şekilde görüntülemenin birkaç yolu vardır. TextBox bir dizinin Başı, Ortası veya Kuyruğu olabilir.
Aşağıdaki kod örneği, TextBox‘in dizinin Başı, Sonu veya Ortası olup olmadığının nasıl kontrol edileceğini gösterir:
// 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."); | |
} |
Bağlantıyı Kırmak
BreakForwardLink yöntemini kullanarak bir sonraki TextBox‘ye olan bağlantıyı kesebilirsiniz.
Aşağıdaki kod örneği, bir TextBox bağlantısının nasıl kesileceğini gösterir:
// 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(); |