Removing an Item from the Gantt Chart
Details
Date:10/17/2008 6:09:00 AM
Product:ActiveGanttCSN Gantt Chart / Scheduler Component
Framework:.Net Framework 1.0
Version:2.7.0.0
User's Development Environment:C# Visual Studio 2002
Subject:Removing an object
Question

In ActiveGantt Scheduler, after adding(dragging with mouse on the scheduler) a Task Object, I can't remove it. Only I can replace it or make it smaller. But, I want to remove the unwanted Tasks. Any solution for this? ( e.g. Can we write some event on right click of the task to remove it?). If the unwanted tasks can be removed, then please send me an example.

Answer

Answer:

The complete code would be the following:



            int lIndexSelected;

 

 

            private void activeGanttCSNCtl1_ObjectSelected(object sender, AGCSN.E_EVENTTARGET EventTarget, int ObjectIndex, int ParentObjectIndex)

            {

                  if (EventTarget == AGCSN.E_EVENTTARGET.EVT_TASK)

                  {

                        lIndexSelected = ObjectIndex;

                  }

                  else

                  {

                        lIndexSelected = 0;

                  }

 

            }

 

            private void button1_Click(object sender, System.EventArgs e)

            {

                  if (lIndexSelected != 0)

                  {

                        activeGanttCSNCtl1.Tasks.Remove(activeGanttCSNCtl1.StrLib.StrCStr(lIndexSelected));

                        activeGanttCSNCtl1.Redraw();

                  }

            }

We used a button instead of a menu for sake of brevity. All objects contained in a collection, not only Task objects have a remove method.

 

All trademarks are property of their respective holders, and are only used to directly describe the products and services being provided. Their use in no way indicates any relationship or endorsement between The Source Code Store LLC and the holders of said trademarks.