BorderIsVisible Property

Returns true if the LineStyle is not LineStyle.None.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public bool IsVisible { get; }

Property Value

Type: Boolean
Examples
Shows the equality of BorderCollections as well counting, visibility of their elements.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.CurrentParagraph.AppendChild(new Run(doc, "Paragraph 1."));

Paragraph firstParagraph = doc.FirstSection.Body.FirstParagraph;
BorderCollection firstParaBorders = firstParagraph.ParagraphFormat.Borders;

builder.InsertParagraph();
builder.CurrentParagraph.AppendChild(new Run(doc, "Paragraph 2."));

Paragraph secondParagraph = builder.CurrentParagraph;
BorderCollection secondParaBorders = secondParagraph.ParagraphFormat.Borders;

// Two paragraphs have two different BorderCollections, but share the elements that are in from the first paragraph
for (int i = 0; i < firstParaBorders.Count; i++)
{
    Assert.IsTrue(firstParaBorders[i].Equals(secondParaBorders[i]));
    Assert.AreEqual(firstParaBorders[i].GetHashCode(), secondParaBorders[i].GetHashCode());

    // Borders are invisible by default
    Assert.IsFalse(firstParaBorders[i].IsVisible);
}

// Each border in the second paragraph collection becomes no longer the same as its counterpart from the first paragraph collection
// There are always 6 elements in a border collection, and changing all of them will make the second collection completely different from the first
secondParaBorders[BorderType.Left].LineStyle = LineStyle.DotDash;
secondParaBorders[BorderType.Right].LineStyle = LineStyle.DotDash;
secondParaBorders[BorderType.Top].LineStyle = LineStyle.DotDash;
secondParaBorders[BorderType.Bottom].LineStyle = LineStyle.DotDash;
secondParaBorders[BorderType.Vertical].LineStyle = LineStyle.DotDash;
secondParaBorders[BorderType.Horizontal].LineStyle = LineStyle.DotDash;

// Now the BorderCollections both have their own elements
for (int i = 0; i < firstParaBorders.Count; i++)
{
    Assert.IsFalse(firstParaBorders[i].Equals(secondParaBorders[i]));
    Assert.AreNotEqual(firstParaBorders[i].GetHashCode(), secondParaBorders[i].GetHashCode());
    // Changing the line style made the borders visible
    Assert.IsTrue(secondParaBorders[i].IsVisible);
}
See Also