ViewSchedule.GroupHeaders
Description:
Groups schedule header cells.
Groups schedule header cells.
public void GroupHeaders(
int top,
int left,
int bottom,
int right,
string caption
)
-
Int32topThe index of the top row of the selected headers.
-
Int32leftThe index of the left column of the selected headers.
-
Int32bottomThe index of the bottom row of the selected headers.
-
Int32rightThe index of the right column of the selected headers.
-
StringcaptionThe header caption.
public static void CreateSingleCategoryScheduleWithGroupedColumnHeaders(Document doc)
{
using (Transaction t = new Transaction(doc, "Create single-category with grouped column headers"))
{
// Build the schedule
t.Start();
ViewSchedule vs = ViewSchedule.CreateSchedule(doc, new ElementId(BuiltInCategory.OST_Windows));
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.WINDOW_HEIGHT));
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.WINDOW_WIDTH));
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.ALL_MODEL_MARK));
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.ALL_MODEL_COST));
doc.Regenerate();
// Group the headers in the body section using ViewSchedule methods
vs.GroupHeaders(0, 0, 0, 1, "Size");
vs.GroupHeaders(0, 2, 0, 3, "Other");
vs.GroupHeaders(0, 0, 0, 3, "All");
t.Commit();
}
}
/// <summary>
/// Adds a single parameter field to the schedule
/// </summary>
public static void AddRegularFieldToSchedule(ViewSchedule schedule, ElementId paramId)
{
ScheduleDefinition definition = schedule.Definition;
// Find a matching SchedulableField
SchedulableField schedulableField =
definition.GetSchedulableFields().FirstOrDefault<SchedulableField>(sf => sf.ParameterId == paramId);
if (schedulableField != null)
{
// Add the found field
definition.AddField(schedulableField);
}
}
-
Headers could not be grouped.
-
A non-optional argument was null