Skip to main content
All docs
V19.1
.NET Framework 4.5.2+
Row

IRangeProvider.Union(Range[]) Method

Creates a complex range that is the union of multiple ranges.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

Range Union(
    params Range[] ranges
)

Parameters

Name Type Description
ranges Range[]

An array of Range objects.

Returns

Type Description
Range

A Range composed of multiple ranges.

Remarks

A complex (union) range can be also created by multiple selection in a worksheet. A complex range can be used in the same manner as a simple range. The Range.Areas property provides access to the ranges to which a complex range is comprised.

This example demonstrates how to create a complex (union) range. There are several ways to accomplish this.

Ranges which comprise a complex range can be accessed using the Range.Areas property.

Range rangeA1D4 = worksheet["A1:D4"];
Range rangeD5E7 = worksheet["D5:E7"];
Range rangeRow11 = worksheet["11:11"];
Range rangeF7 = worksheet["F7"];

// Create a complex range using the Range.Union method.
Range complexRange1 = worksheet["A7:A9"].Union(rangeD5E7);

// Create a complex range using the IRangeProvider.Union method.
Range complexRange2 = worksheet.Range.Union(new Range[] { rangeRow11, rangeA1D4, rangeF7 });

// Fill the ranges with different colors.
complexRange1.FillColor = myColor1;
complexRange2.FillColor = myColor2;

// Use the Areas property to get access to a component of a complex range.
complexRange2.Areas[2].FillColor = Color.Beige;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Union(Range[]) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also