Click or drag to resize
MultipleBordersAdd Method
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.

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1231
Syntax
public void Add(
	MultipleBorderTypes borderTypes,
	BorderStyle borderStyle,
	Color borderColor,
	double borderWidth
)

Parameters

borderTypes
Type: GemBox.DocumentMultipleBorderTypes
The border types to set.
borderStyle
Type: GemBox.DocumentBorderStyle
The border style.
borderColor
Type: GemBox.DocumentColor
The border color.
borderWidth
Type: SystemDouble
The border width in points.
Remarks

MultipleBorders class explicitly implements IEnumerable and contains public method Add(MultipleBorderTypes, BorderStyle, Color, Double) so it can be initialized using the C# collection initializer syntax like in the following example.

Examples

Following example shows how to initialize outside and inside table borders using the C# collection initializer syntax.

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

// Insert a 5x5 table with single red outside borders and dashed blue inside borders.
doc.Sections.Add(
    new Section(doc,
        new Table(doc, 5, 5)
        {
            TableFormat = new TableFormat()
            {
                Borders =
                {
                    { MultipleBorderTypes.Outside, BorderStyle.Single, Color.Red, 2 },
                    { MultipleBorderTypes.Inside, BorderStyle.Dashed, Color.Blue, 1 }
                }
            }
        }));

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

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

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