RadiantQ WPF Gantt
How to Prevent Resizing a Taskbar?
Previous Topic  Next Topic 

How To Prevent Resizing a Taskbar?


In order to prevent a taskbar from resizing CanResizeActivity event can be used.


Below is the code usage,


public partial class MainPage : Page

{

    public MainPage()

    {

        this.ganttControl.CanResizeActivity += ganttControl_CanResizeActivity;

    }


    void ganttControl_CanResizeActivity(object sender, CancellableActivityEventArgs e)

    {

        // prevents taskbar resizing

        // here resizing taskbar named Task 2 will be prevented

        // Or use this to get hold of the underlying bound object:

        // (YourTaskType)((DataBoundActivity)e.Activity).DataSource

        if (e.Activity.ActivityName == "Task 2")

            e.Cancel = true;

    }

}



Similarly, taskbar shifting can also be prevented using CanShiftActivity as shown below.


public partial class MainPage : Page

{

    public MainPage()

    {

        this.ganttControl.CanShiftActivity += ganttControl_CanShiftActivity;

    }


    void ganttControl_CanShiftActivity(object sender, CancellableActivityEventArgs e)

    {

        // prevents moving taskbar

        // here shifting/moving taskbar named Task 3 will be prevented

        // Or use this to get hold of the underlying bound object:

        // (YourTaskType)((DataBoundActivity)e.Activity).DataSource

        if (e.Activity.ActivityName == "Task 3")

            e.Cancel = true;

    }

}




� RadiantQ 2009 - 2019. All Rights Reserved.