Sets cell style override options of this cell.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since:
2014
Syntax
Examples
CopyC#
public static void ApplyFormattingToField(ViewSchedule schedule, int fieldIndex)
{
ScheduleDefinition definition = schedule.Definition;
ScheduleField field = definition.GetField(fieldIndex);
FormatOptions options = field.GetFormatOptions();
options.UseDefault = false;
options.SetUnitTypeId(UnitTypeId.SquareInches);
options.SetSymbolTypeId(SymbolTypeId.InSup2);
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);
field.GridColumnWidth = width + 0.5;
t.Commit();
}
}
CopyVB.NET
Public Shared Sub ApplyFormattingToField(schedule As ViewSchedule, fieldIndex As Integer)
Dim definition As ScheduleDefinition = schedule.Definition
Dim field As ScheduleField = definition.GetField(fieldIndex)
Dim options As FormatOptions = field.GetFormatOptions()
options.UseDefault = False
options.SetUnitTypeId(UnitTypeId.SquareInches)
options.SetSymbolTypeId(SymbolTypeId.InSup2)
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)
field.GridColumnWidth = width + 0.5
t.Commit()
End Using
End Sub
Exceptions
See Also