View

View class

Represents a view in Project.

public class View : IComparable<View>

Constructors

Name Description
View() Initializes a new instance of the View class.
View(ViewScreen) Initializes a new instance of the View class.

Properties

Name Description
Filter { get; set; } Gets or sets a filter used in a single view.
Group { get; set; } Gets or sets a group of the single view.
HighlightFilter { get; set; } Gets or sets a value indicating whether Microsoft Project highlights the filter for a single view.
Name { get; set; } Gets or sets the name of a View object.
PageInfo { get; } Gets an instance of the PageInfo class. Represents page setup data which is present in mpp file format.
ParentProject { get; } Gets the parent of the View object. Read-only Project.
Screen { get; } Gets the screen type for the single view. Read-only ViewScreen.
ShowInMenu { get; set; } Gets or sets a value indicating whether Microsoft Project shows the single view name in the View or the Other Views drop-down lists in the Ribbon.
Table { get; set; } Gets or sets a table of the single view.
Type { get; } Gets the type of item in the single view, such as tasks or resources. Read-only ItemType.
Uid { get; } Gets the unique identifier of a view.
VisualObjectsPlacements { get; } Gets a collection of objects representing placement and appearance of OleObject in the view.

Methods

Name Description
CompareTo(View) Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
override Equals(object) Returns a value indicating whether this instance is equal to a specified object.
override GetHashCode() Returns a hash code value for the instance of the Resource class.
operator == Returns a value indicating whether this instance is equal to a specified object.
operator > Returns a value indicating whether this instance is greater than a specified object.
operator >= Returns a value indicating whether this instance is greater than or equal to a specified object.
operator != Returns a value indicating whether this instance is not equal to a specified object.
operator < Returns a value indicating whether this instance is less than a specified object.
operator <= Returns a value indicating whether this instance is less than or equal to a specified object.

Examples

Shows how to work with MS Project views.

// create an empty project without views 
var project = new Project();
project.Set(Prj.Name, "Test View Project");

// create a standard Gantt chart view
View view = new GanttChartView();

// set some view properties
// set a value indicating whether Microsoft Project shows the single view name in the View or the Other Views drop-down lists in the Ribbon
view.ShowInMenu = true;
// set a value indicating whether Microsoft Project highlights the filter for a single view
view.HighlightFilter = true;

// the writing of the next properties is not supported
// sets the filter used in a single view
view.Filter = null;
// sets the group of the single view
view.Group = null;
// sets the table of the single view
view.Table = null;

// lets tune some view settings
// set the number of first columns to be printed on all pages
view.PageInfo.PageViewSettings.FirstColumnsCount = 4;
// set a value indicating whether to print a specified number of first columns on all pages
view.PageInfo.PageViewSettings.PrintFirstColumnsCountOnAllPages = true;

// add the view to the our project
project.Views.Add(view);

// WriteViewData flag should be used to persist modifications of project.Views.
project.Save(OutDir + "WorkWithView_output.mpp", new Saving.MPPSaveOptions
{
    WriteViewData = true
});
// lets check some properties of the newly added view
// print the unique identifier of a view
Console.WriteLine("View Uid: " + view.Uid);
// print the screen type for the single view
Console.WriteLine("View Screen: " + view.Screen);
Console.WriteLine("View Type: " + view.Type);
Console.WriteLine("Parent Project of the view: " + view.ParentProject.Get(Prj.Name));

See Also