Click or drag to resize
SingleBorder Structure
Represents a single border around a document element.

Namespace:  GemBox.Document
Assembly:  GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1243
Syntax
public struct SingleBorder : IEquatable<SingleBorder>

The SingleBorder type exposes the following members.

Constructors
  NameDescription
Public methodSingleBorder
Initializes a new instance of the SingleBorder struct.
Top
Properties
  NameDescription
Public propertyColor
Gets the border color.
Public propertyStyle
Gets the border style.
Public propertyWidth
Gets the border width in points.
Top
Methods
  NameDescription
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.)
Public methodToString
Returns a String that represents this SingleBorder instance.
(Overrides ValueTypeToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether first and second SingleBorders are equal.
Public operatorStatic memberInequality
Determines whether first and second SingleBorders are not equal.
Top
Fields
  NameDescription
Public fieldStatic memberNone
Value that represents that there is no border.
Top
Remarks
SingleBorder defines a border line pattern style, color and width for a single border around an element. SingleBorder is only directly used in a CharacterFormat.Border property, otherwise it is contained in a ParagraphFormat.Borders, TableFormat.Borders or TableCellFormat.Borders properties.
Examples

Following example shows how to create a document that demonstrates all available border styles.

// Get all border styles.
var borderStyles = (BorderStyle[])Enum.GetValues(typeof(BorderStyle));

// Create a new empty document.
var doc = new DocumentModel();

// Insert a table with 1 column and 'borderStyles.Length' rows.
doc.Sections.Add(
    new Section(doc, 
        new Table(doc, borderStyles.Length, 1, (row, column) =>
        {
            // Create a new table cell with text taken from 'borderStyles' array at index 'row'.
            var cell = new TableCell(doc, new Paragraph(doc, borderStyles[row].ToString()));

            // Set cell outside borders to red color, with width of 2 points and with border style taken from 'borderStyles' array at index 'row'.
            cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, borderStyles[row], Color.Red, 2d);

            return cell;
        })));

// Document will be saved to the Desktop.
var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Borders.docx");

// Save the document.
doc.Save(path);

// Open the document in Microsoft Word.
System.Diagnostics.Process.Start(path);
See Also