Search Results for

    Show / Hide Table of Contents

    Class ColorHelper

    Provides utility methods for parsing and converting color values from various input formats. Supports named colors, HEX strings, RGB/ARGB values, and ARGB integer representations.

    Inheritance
    System.Object
    ColorHelper
    Namespace: FastReport.Utils
    Assembly: FastReport.Base.dll
    Syntax
    public static class ColorHelper

    Methods

    FromObject(Object, Color)

    Converts an object of various types to a . If the conversion fails, returns a fallback color (default: ).

    Declaration
    public static Color FromObject(object value, Color fallback = null)
    Parameters
    Type Name Description
    System.Object value

    The input value. Supported types:

    • - returned as-is.
    • System.Int32 - interpreted as an ARGB value.
    • System.String - parsed using FromString(String).
    Any other type treated as invalid.

    Color fallback

    The color to return if conversion fails. If not specified, defaults to .

    Returns
    Type Description
    Color

    A valid instance. Never returns null.

    FromString(String)

    Parses a string representation of a color into a structure.

    Declaration
    public static Color? FromString(string input)
    Parameters
    Type Name Description
    System.String input

    The string to parse. Can be:

    • A named color (e.g., "Red", "DarkBlue")
    • A HEX color in formats "#RGB", "#RRGGBB", or "#AARRGGBB" (e.g., "#F00", "#FF0000", "#80FF0000")
    • An RGB or ARGB values as comma-separated integers (e.g., "255,0,255" or "128,255,0,255")
    • An ARGB integer as a decimal string (e.g., the result of Color.ToArgb().ToString())

    Returns
    Type Description
    System.Nullable<Color>

    A if parsing succeeded; otherwise, null.

    Remarks

    The method processes input in the following order:

    Back to top © 1998-2026 Copyright Fast Reports Inc.