ShowPropertyPage() for Version 2.0

Jan 18, 2010 at 8:23 AM

Hi,   I need to show the Property page for V 2.0, But i haven't seen any method which do that, I have seen one method ShowPropertyPage() which only works for V 1.0 , So what is the best way to show the Property Page for a particular task in  Version2?.

Jan 21, 2010 at 5:34 PM

Microsoft removed any native support for programatically calling the editor interface in 2.0. For this reason, we have created the TaskSchedulerEditor control library as a suppliment to the TaskScheduler library. You will find the library as another file to download in the release area.

To use the control, you effectively add it to a Form setup as a dialog or you can host it directly within your application. Assuming you have added it to a form, below is a small function that would call it:

static void ShowPropertyPage(string taskName)
  // Get the service on the local machine
  using (TaskService ts = new TaskService())
    // Edit task
    Task t = ts.GetTask(taskName);
    TaskDefinition td = DisplayTask(t, true);

    // Register if changed
    if (td != null)
      ts.RootFolder.RegisterTaskDefinition(taskName, td);

static TaskDefinition DisplayTask(Task t, bool editable)
  Form1 frm = new Form1();
  frm.taskPropertiesControl1.Editable = editable;
  return (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) ? frm.taskPropertiesControl1.TaskDefinition : null;