I have been running into some issues creating schedules so i thought i would share some data for you all;
Centering Text in a Schedule Column (field):
Code:
//Create a schedule
ViewSchedule schedule = ViewSchedule.CreateSchedule(document, new ElementId(BuiltInCategory.OST_#########)); //Set Category
//Add Your Code for Fields / Sorting / Filtering
//
//
//Create Section Data for Headers / Body
TableSectionData tsd = schedule.GetTableData().GetSectionData(SectionType.Header);
TableSectionData tsdbody = schedule.GetTableData().GetSectionData(SectionType.Body);
//Create Style and Override Options
TableCellStyle tcs = new TableCellStyle();
TableCellStyleOverrideOptions tcsOpt = new TableCellStyleOverrideOptions();
//Set Override Options
tcsOpt.HorizontalAlignment = true; //Set Override to True to allow for centering
tcs.SetCellStyleOverrideOptions(tcsOpt); //Commit the Options
//Set Font Styling
tcs.FontHorizontalAlignment = HorizontalAlignmentStyle.Center;
//Commit the Styles
tsd.SetCellStyle(tsd.FirstColumnNumber, tcs); //Header - First Column
tsdbody.SetCellStyle(tsdbody.FirstColumnNumber, tcs); //Body - First Column
Adding Count to Schedule Column (field):
Code:
//Create a schedule
ViewSchedule schedule = ViewSchedule.CreateSchedule(document, new ElementId(BuiltInCategory.OST_#########)); //Set Category
//Add Count to Schedule Field
schedule.Definition.AddField(ScheduleFieldType.Count);
It may not be rocket science but it kicked my *** for awhile so i thought i would share.