ViewCollection Class |
Namespace: Aspose.Tasks
The ViewCollection type exposes the following members.
| Name | Description | |
|---|---|---|
| Count |
Gets the number of elements contained in this collection.
| |
| IsReadOnly |
Gets a value indicating whether this collection is read-only; otherwise, false.
| |
| ParentProject |
Gets the parent of the View object.
Read-only Project.
|
| Name | Description | |
|---|---|---|
| Add |
Adds the specified item to this collection.
| |
| Clear |
Removes all items from this collection.
| |
| Contains |
Returns true if the specified item is found in this collection; otherwise, false.
| |
| CopyTo |
Copies the elements of this collection to the specified array, starting at the specified array index.
| |
| Equals | (Inherited from Object.) | |
| Finalize | (Inherited from Object.) | |
| GetByName |
Searches for a View with the name, and returns the first occurrence within the collection.
| |
| GetByViewScreen |
Searches for a View with the specified Screen property, and returns the first occurrence within the collection.
| |
| GetEnumerator |
Returns an enumerator for this collection.
| |
| GetHashCode | (Inherited from Object.) | |
| GetType | (Inherited from Object.) | |
| MemberwiseClone | (Inherited from Object.) | |
| Remove |
Removes the first occurrence of a specific object from this collection.
| |
| ToList |
Converts a view collection to a list of View objects.
| |
| ToString | (Inherited from Object.) |
var project = new Project(DataDir + "Project1.mpp"); // convert to a plain list of views List<View> list = project.Views.ToList(); for (var index = 0; index < list.Count; index++) { var viewToChange = list[index]; viewToChange.PageInfo.Header.CenteredText = "Header " + index; } // add a new view var view = new GanttChartView(); if (!project.Views.IsReadOnly) { project.Views.Add(view); } // iterate over views Console.WriteLine("Iterate over views of " + project.Views.ParentProject.Get(Prj.Name) + " project."); Console.WriteLine("Project view count: " + project.Views.Count); Console.WriteLine(); foreach (var projectView in project.Views) { Console.WriteLine("Name: " + projectView.Name); } // remove all views at once project.Views.Clear(); // or one by one { // approach 1 List<View> listToDelete = project.Views.ToList(); foreach (var v in listToDelete) { if (project.Views.Contains(v)) { project.Views.Remove(v); } } } { // approach 2 var array = new View[project.Views.Count]; project.Views.CopyTo(array, 0); foreach (var v in array) { if (project.Views.Contains(v)) { project.Views.Remove(v); } } }