10135 : Binding time items from an ArrayList

This is how you can bind a layer in a GanttRow to show the your data from an ArrayList as Time Items in the Gantt:

// If you have data with two DateTime properties….

      class TimedThing:object
      {
        public TimedThing(DateTime start,DateTime stop)
        {
          Start=start;
          Stop=stop;
        }
        private DateTime fstart;
        private DateTime fstop;
        public DateTime Start
        {
          get{return fstart;}
          set{fstart=value;}
        }
        public DateTime Stop
        {
          get{return fstop;}
          set{fstop=value;}
        }
      }

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

// …And you put such objects in an arraylist…
      ArrayList myTimeItems=new ArrayList();
      myTimeItems.Add(new TimedThing(DateTime.Today,DateTime.Today.AddDays(1)));
      myTimeItems.Add(new TimedThing(DateTime.Today.AddDays(2),DateTime.Today.AddDays(3)));
      myTimeItems.Add(new TimedThing(DateTime.Today.AddDays(4),DateTime.Today.AddDays(5)));
      myTimeItems.Add(new TimedThing(DateTime.Today.AddDays(6),DateTime.Today.AddDays(7)));
      myTimeItems.Add(new TimedThing(DateTime.Today.AddDays(8),DateTime.Today.AddDays(9)));

      GanttRow gr1=GanttRow.FromGridNode(gantt1.Grid.GridStructure.RootNodes[0]);
      Layer l=gr1.Layers.AddLayer();

// Then you can set up the Layer to display your properties as start and stop for time items
      l.NameInDS_Start=”Start”;
      l.NameInDS_Stop=”Stop”;
      l.DataSourceList=myTimeItems;

// cool…     

    }
   

Leave a Reply