how to use RecurrenceTask in an array?

2 posts, 0 answers
  1. yongcheol
    yongcheol avatar
    3 posts
    Member since:
    Jun 2020

    Posted 29 Jul Link to this post


    <br>    RecurrenceTask[] RecurrenceTask_Array = new RecurrenceTask[3];
                for (int i = 0; i < RecurrenceTask_Array.Length; i++)
                {
                    RecurrenceTask_Array[i] = new RecurrenceTask(today.AddYears(11), today.AddHours(1), "Recurrence Series" + i.ToString())
                    {
                        Recurrences = { recurrenceTask1, recurrenceTask2, recurrenceTask3 }
                    };
                }
                for (int i = 0; i < RecurrenceTask_Array.Length; i++)
                {
                    gts[0].Children.Add(RecurrenceTask_Array[i]);
                    gts[1].Children.Add(RecurrenceTask_Array[i]);
                }
                for (int i = 0; i < gts.Length; i++)
                {
                    this.Tasks.Add(gts[i]);
                }

    this source occur argumentException
    can i use RecurrenceTask in array?

     


  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    703 posts

    Posted 31 Jul Link to this post

    Hello Yongcheol,

    Thank you for the shared code snippet. 

    It seems that you are using the SameRowRecurringTask SDK example. I tested the specified code snippet and there isn't anything wrong with using the RecurrenceTask in an array. The problem is that the same object is added multiple times in the RadGanttView. You can notice that the in the 2nd for loop "RecurrenceTask_Array[i]" is added to the 1st and 2nd GanttTask. Instead, you need to create new instances of the RecurrenceTask objects. 

    Please, find the mentioned SDK example updated to demonstrate how you can populate the RecurrenceTasks. Do check it out and let me know, if it helps. 

    Regards,
    Vladimir Stoyanov
    Progress Telerik

Back to Top