SetCellStyleOverrideOptions Method


Sets cell style override options of this cell.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2014

Syntax

C#
public void SetCellStyleOverrideOptions(
	TableCellStyleOverrideOptions helper
)
Visual Basic
Public Sub SetCellStyleOverrideOptions ( _
	helper As TableCellStyleOverrideOptions _
)
Visual C++
public:
void SetCellStyleOverrideOptions(
	TableCellStyleOverrideOptions^ helper
)

Examples

Copy C#
public static void ApplyFormattingToField(ViewSchedule schedule, int fieldIndex)
{
    // Get the field.
    ScheduleDefinition definition = schedule.Definition;
    ScheduleField field = definition.GetField(fieldIndex);

    // Build unit formatting for the field.
    FormatOptions options = field.GetFormatOptions();
    options.UseDefault = false;
    options.DisplayUnits = DisplayUnitType.DUT_SQUARE_INCHES;
    options.UnitSymbol = UnitSymbolType.UST_IN_SUP_2;

    // Build style overrides for the field
    // Use override options to indicate fields that are overridden and apply changes
    TableCellStyle style = field.GetStyle();
    TableCellStyleOverrideOptions overrideOptions = style.GetCellStyleOverrideOptions();
    overrideOptions.BackgroundColor = true;
    style.BackgroundColor = new Color(0x00, 0x00, 0xFF);
    overrideOptions.FontColor = true;
    style.TextColor = new Color(0xFF, 0xFF, 0xFF);
    overrideOptions.Italics = true;
    style.IsFontItalic = true;

    style.SetCellStyleOverrideOptions(overrideOptions);

    double width = field.GridColumnWidth;

    using (Transaction t = new Transaction(schedule.Document, "Set style etc"))
    {
        t.Start();
        field.SetStyle(style);
        field.SetFormatOptions(options);
        // Change column width (affects width in grid and on sheet) - units are in Revit length units - ft.
        field.GridColumnWidth = width + 0.5;
        t.Commit();
    }
}
Copy VB.NET
Public Shared Sub ApplyFormattingToField(schedule As ViewSchedule, fieldIndex As Integer)
    ' Get the field.
    Dim definition As ScheduleDefinition = schedule.Definition
    Dim field As ScheduleField = definition.GetField(fieldIndex)

    ' Build unit formatting for the field.
    Dim options As FormatOptions = field.GetFormatOptions()
    options.UseDefault = False
    options.DisplayUnits = DisplayUnitType.DUT_SQUARE_INCHES
    options.UnitSymbol = UnitSymbolType.UST_IN_SUP_2

    ' Build style overrides for the field
    ' Use override options to indicate fields that are overridden and apply changes
    Dim style As TableCellStyle = field.GetStyle()
    Dim overrideOptions As TableCellStyleOverrideOptions = style.GetCellStyleOverrideOptions()
    overrideOptions.BackgroundColor = True
    style.BackgroundColor = New Color(&H0, &H0, &HFF)
    overrideOptions.FontColor = True
    style.TextColor = New Color(&HFF, &HFF, &HFF)
    overrideOptions.Italics = True
    style.IsFontItalic = True

    style.SetCellStyleOverrideOptions(overrideOptions)

    Dim width As Double = field.GridColumnWidth

    Using t As New Transaction(schedule.Document, "Set style etc")
        t.Start()
        field.SetStyle(style)
        field.SetFormatOptions(options)
        ' Change column width (affects width in grid and on sheet) - units are in Revit length units - ft.
        field.GridColumnWidth = width + 0.5
        t.Commit()
    End Using
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL

See Also