Free Support Forum - aspose.com

How to set styles to custom fields in Aspose.Tasks?


#1

Hello,

I have created a custom filed using Aspose.Tasks component and able to add data to custom field column as well. But, I would like to make styling ((fore color, font size, etc) for data for custom field. I wonder how to do this using Aspose.Tasks.

My scenario is, based on the value of the fields I need to set ForeColor green/red to that cell. Please let me know what is the best way to do this…

Thanks,
Srinivas


#2

@srinudhulipalla

We have logged your requirement with ID “TASKSNET-2816” for further investigation. You will automatically be informed here once we have more information to share.


#3

Thanks and I will be waiting…


#4

The issues you have found earlier (filed as TASKSNET-2816) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan


#5

@MuzammilKhan
Thanks for fixing the issue in new version. Moreover I have not seen the changes to component on where to apply this, probably I might be missing the place. Do you have the documentation or sample example on this?


#6

@srinudhulipalla

You may use the code sample given below:

       internal sealed class MyTextStyleCallback : ITextStyleModificationCallback
        {
            public void BeforeTaskTextStyleApplied(TaskTextStyleEventArgs args)
            {
                if (args.Task.Get(Tsk.Uid) % 2 == 0)
                {
                    args.CellTextStyle.BackgroundColor = Color.Cyan;
                    args.CellTextStyle.BackgroundPattern = BackgroundPattern.SolidFill;
                }
            }
        }

        public void Test1()
        {
            var project = new Project("c:\\test\\New Project 2016.mpp");

            var view = ProjectView.GetDefaultTaskSheetView();
            view.Columns[0].TextStyleModificationCallback = new MyTextStyleCallback();
            project.Save("c:\\Project_Exported.pdf",
                new PdfSaveOptions
                    {
                        PageSize = PageSize.A3,
                        View = view,
                        PresentationFormat = PresentationFormat.GanttChart
                    });
        }

Moreover, we will make it a part of our documentation. Please share your feedback and feel free to write back to us if any further information is required.