Click or drag to resize
MultipleBorders Class
Represents a set of borders.
Inheritance Hierarchy
SystemObject
  GemBox.DocumentMultipleBorders

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1231
Syntax
public sealed class MultipleBorders : IEnumerable

The MultipleBorders type exposes the following members.

Methods
  NameDescription
Public methodCode exampleAdd
Sets the specified borders. This method is required to support C# collection initializer syntax and redirects its call to the SetBorders(MultipleBorderTypes, BorderStyle, Color, Double) method.
Public methodClearBorders
Clears all borders.
Public methodClearBorders(MultipleBorderTypes)
Clears the specified borders.
Public methodEquals
Determines whether the specified Object is equal to this MultipleBorders instance.
(Overrides ObjectEquals(Object).)
Public methodGetHashCode
Returns a hash code for this MultipleBorders instance.
(Overrides ObjectGetHashCode.)
Public methodCode exampleSetBorders
Sets the specified borders.
Public methodStatic memberToSingleBorderTypes
Converts a MultipleBorderTypes flags enumeration to a sequence of SingleBorderType enumeration.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether first and second MultipleBorderss are equal.
Public operatorStatic memberInequality
Determines whether first and second MultipleBorderss are not equal.
Top
Properties
  NameDescription
Public propertyItem
Gets the SingleBorder for the specified SingleBorderType.
Public propertySupportedBorderTypes
Gets the supported border types.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodCode exampleIEnumerableGetEnumerator

Returns an enumerator that iterates through all SingleBorders supported in this MultipleBorders instance.

IEnumerable interface is required to support C# collection initializer syntax.

Top
Remarks
MultipleBorders class is used to set borders for Paragraph, Table and TableCell elements.

Paragraph supports only Outside borders, Table supports Outside and Inside borders, and TableCell supports All.

To programmatically enumerate through all supported border types, use SupportedBorderTypes property.

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