11061 : Multiselect in the TimeItemArea

Question

I know you can multiselect time items by holding the ctrl key while clicking them, and that you can get to all selected time items by the method gantt1.GetSelectedTimeItems().

But what if I do not allow multi select? How can I stop it?

Answer

To effectively stop multiselect for the TimeItems go like this:< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

    gantt1.OnTimeItem_SelectionChanged += new TimeItemEvent(gantt1_OnTimeItem_SelectionChanged);

 

    void gantt1_OnTimeItem_SelectionChanged(Gantt aGantt, TimeItemEventArgs e)

    {

      if (e.TimeItem.Selected)

      {

        foreach(TimeItem ti in gantt1.GetSelectedTimeItems())

        {

          if (ti!=e.TimeItem)

            ti.Selected=false;

        }

      }

    }

 

Leave a Reply