Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GradientFill.FillRect Property

Specifies the gradient fill direction.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

#Declaration

RectangleOffset FillRect { get; set; }

#Property Value

Type Description
RectangleOffset

An object that specifies offsets (in percentage) from the fill rectangle edges to the center shade rectangle.

#Remarks

Use the FillRect property to specify a gradient direction. It depends on the gradient type applied to a shape (GradientFill.GradientType). The FillRect property defines the position of the center shade relative to the fill rectangle.

#Example 1

In the example below, the center shade occupies the entire shape except for the topmost, leftmost, and rightmost 25% of the rectangle. The gradient fills the remaining area.

Rich_GradientFill_FillRect_Example

// Add a rectangle to the document.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, new RectangleF(300, 200, 500, 300));
// Fill the rectangle with a gradient.
rectangle.Fill.SetGradientFill(GradientType.Rectangle, Color.FromArgb(0xF6, 0xCD, 0x61), Color.FromArgb(0xEE, 0x40, 0x35));
// Specify the gradient direction.
rectangle.Fill.GradientFill.FillRect = new RectangleOffset(0.25f, 0.25f, 0.25f, 0f);

#Example 2

This example creates a rectangle with a gradient direction that starts from the bottom right corner.

Rich_GradientFill_FillRect_From_Corner

// Add a rectangle to the document.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, new RectangleF(300, 200, 500, 300));
// Fill the rectangle with a gradient.
rectangle.Fill.SetGradientFill(GradientType.Rectangle, Color.FromArgb(0xF6, 0xCD, 0x61), Color.FromArgb(0xEE, 0x40, 0x35));
// Specify the following gradient direction: "From Bottom Right Corner".
rectangle.Fill.GradientFill.FillRect = new RectangleOffset(1f, 1f, 0f, 0f);

#Example 3

The example below creates a circle with a radial gradient direction that starts from the center. The FillRect property defines a point in the center of the shape.

Rich_GradientFill_FillRect_From_Center

// Add a circle to the document.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Oval, new RectangleF(300, 200, 500, 500));
// Apply a three-color gradient to the circle.
GradientStop stop1 = new GradientStop(0f, Color.FromArgb(0xFE, 0xD7, 0x66));
GradientStop stop2 = new GradientStop(0.5f, Color.FromArgb(0xFF, 0x33, 0x77));
GradientStop stop3 = new GradientStop(1f, Color.FromArgb(0x2A, 0x4D, 0x69));
rectangle.Fill.SetGradientFill(GradientType.Circle, new GradientStop[] { stop1, stop2, stop3 });
// Specify the following gradient direction: "From Center".
rectangle.Fill.GradientFill.FillRect = new RectangleOffset(0.5f, 0.5f, 0.5f, 0.5f);
See Also