Aspose.Tasks.Examples.CSharp.WorkingWithProjects.WorkingWithProjectViews.ConfigureGantChart.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {
                // ExStart:ConfigureGantChart
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); 
                Project project = new Project(dataDir + "Project5.mpp"); // Create a new project task
                Task task = project.RootTask.Children.Add("New Activity");

                // Add custom text attribute to created task.
                ExtendedAttribute attr = new ExtendedAttribute();
                attr.FieldId = ((int)ExtendedAttributeTask.Text1).ToString();
                attr.Value = "Activity attribute";
                task.ExtendedAttributes.Add(attr);

                // Customize table by adding text attribute field
                TableField attrField = new TableField();
                attrField.Field = Field.TaskText1;
                attrField.Width = 20;
                attrField.Title = "Custom attribute";
                attrField.AlignTitle = StringAlignment.Center;
                attrField.AlignData = StringAlignment.Center;

                Table table = project.Tables.ToList()[0];
                table.TableFields.Insert(3, attrField);
                         
                project.Save(dataDir + "ConfigureGantChart_out.mpp", SaveFileFormat.MPP);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
            // ExEnd:ConfigureGantChart
        }
    }
ConfigureGantChart