Click or drag to resize

SingleBorder Structure

Represents a single border around a document element.
Inheritance Hierarchy
SystemObject
  SystemValueType
    SautinSoft.DocumentSingleBorder

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.11.20
Syntax
public struct SingleBorder : IEquatable<SingleBorder>, 
	IComparable

The SingleBorder type exposes the following members.

Constructors
 NameDescription
Public methodSingleBorder(BorderStyle, Color, Double) Initializes a new instance of the SingleBorder struct.
Public methodSingleBorder(BorderStyle, Color, Double, Double) Initializes a new instance of the SingleBorder struct.
Top
Properties
 NameDescription
Public propertyColor Gets the border color.
Public propertySpacing Gets the border spacing in points.
Public propertyStyle Gets the border style.
Public propertyWidth Gets the border width in points.
Top
Methods
 NameDescription
Public methodCompareTo Compares SingleBorder objects.
Public methodEquals(Object) Determines whether the specified Object is equal to this SingleBorder instance.
(Overrides ValueTypeEquals(Object))
Public methodEquals(SingleBorder) Determines whether the other  SingleBorder is equal to this SingleBorder instance.
Public methodGetHashCode Returns a hash code for this SingleBorder instance.
(Overrides ValueTypeGetHashCode)
Top
Operators
 NameDescription
Public operatorStatic memberEquality(SingleBorder, SingleBorder) Determines whether first and second SingleBorders are equal.
Public operatorStatic memberInequality(SingleBorder, SingleBorder) Determines whether first and second SingleBorders are not equal.
Top
Fields
 NameDescription
Public fieldStatic memberNone Value that represents that there is no border.
Top
Example

See Developer Guide: Detect cell borders with the same color

Detect cell borders with the same color using C#
using System;
using SautinSoft.Document;
using SautinSoft.Document.Tables;


namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/

            DetectBorders();
        }
        /// <summary>
        /// Detect cell borders with the same color.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/from-customers-detect-borders-in-table-csharp-vb-net.php
        /// </remarks>

        private static void DetectBorders()
            {
                DocumentCore dc = DocumentCore.Load(@"..\..\..\example.docx");

            foreach (TableCell itemTC in dc.GetChildElements(true, ElementType.TableCell))
            {
                SingleBorder sbLeft = itemTC.CellFormat.Borders[SingleBorderType.Left];
                SingleBorder sbTop = itemTC.CellFormat.Borders[SingleBorderType.Top];
                SingleBorder sbRight = itemTC.CellFormat.Borders[SingleBorderType.Right];
                SingleBorder sbBottom = itemTC.CellFormat.Borders[SingleBorderType.Bottom];
                if (sbLeft.Color == sbTop.Color && sbTop.Color == sbRight.Color && sbRight.Color == sbBottom.Color)
                {
                    itemTC.Content.Start.Insert("This cell has the same border color.\r\n");
                }
            }

            // Save our document into DOCX format.
            string filePath = "ResultDetectBorder.docx";
            dc.Save(filePath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}
Detect cell borders with the same color using VB.Net
Imports Microsoft.VisualBasic
Imports System
Imports SautinSoft.Document
Imports SautinSoft.Document.Tables


Namespace Example
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            DetectBorders()
        End Sub
                ''' Get your free 100-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Detect cell borders with the same color.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/from-customers-detect-borders-in-table-csharp-vb-net.php
        ''' </remarks>

        Private Shared Sub DetectBorders()
            Dim dc As DocumentCore = DocumentCore.Load("..\..\..\example.docx")

            For Each itemTC As TableCell In dc.GetChildElements(True, ElementType.TableCell)
                Dim sbLeft As SingleBorder = itemTC.CellFormat.Borders(SingleBorderType.Left)
                Dim sbTop As SingleBorder = itemTC.CellFormat.Borders(SingleBorderType.Top)
                Dim sbRight As SingleBorder = itemTC.CellFormat.Borders(SingleBorderType.Right)
                Dim sbBottom As SingleBorder = itemTC.CellFormat.Borders(SingleBorderType.Bottom)
                If sbLeft.Color = sbTop.Color AndAlso sbTop.Color = sbRight.Color AndAlso sbRight.Color = sbBottom.Color Then
                    itemTC.Content.Start.Insert("This cell has the same border color." & vbCrLf)
                End If
            Next itemTC

            ' Save our document into DOCX format.
            Dim filePath As String = "ResultDetectBorder.docx"
            dc.Save(filePath)

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also