10009 : Select a row in the gantt area when a node in the grid is selected

Symptoms

How to select a row in the gantt area when a node in the grid is selected?

 

Resolution

Whenever a cell is selected or de-selected the event Grid.OnCellSelectChanged is fired. If you implement this event and check if the event is fired due to a selection (nowSelected==true), look up the owning GridNode, find the corresponding GanttRow and check if it contains any time items. If so,  select it:

 

gantt1.Grid.OnCellSelectChanged+=

new CellSelectChangedHandler(Grid_OnCellSelectChanged);

    private void Grid_OnCellSelectChanged(Cell cell, CellSelectChangedEventArgs cellSelectChanged)
    {
      if (cellSelectChanged.nowSelected)
      {
        GanttRow gr=Gantt.GanttRowFromGridNode(cell.Node);
        if (gr.Layers.Count>0 && gr.Layers[0].Count>0 )
        {
          gantt1.UpdateMultiSelect(gr.Layers[0][0]);
         
        }
      }
    }

Note; time items has a property Selected that will be set upon selection, but if this state actually shows on screen depends on the TimeItemLayout for the given time item… Try TimeItemLayout.SelectHandles=Color.Black;

Note2; You can set gr.Layers[0][0].Selected=true, but then the earlier selected time items will not be un-selected. 

 

 

Leave a Reply