10219 : Double click time item and bring up a dialog

Question

I would like to be able to double click on an item in the chart and have a popup window that modifies the data and writes it back to our database.  How do I do this?

Answer

This is how you can find out the time item actually double clicked. To change it and update your DB; I leave that up to you, but the best approach would be to use databind for time items See the Gantt_Database or Gantt_DataBind sample in the general download. 

    private void gantt1_OnTimeItemAreaDoubleClick(object sender, System.EventArgs e)
    {
      if (gantt1.FocusedTimeItem!=null)
      {
        MessageBox.Show(gantt1.FocusedTimeItem.GanttRow.GridNode.Index.ToString()+”.”+gantt1.FocusedTimeItem.Index.ToString());
      }
    }

Or if you want find a time item from a given pixel (sample in VB.Net):

Dim selectedTI As TimeItem = gnt_Planung.TimeItemFromPoint(gnt_Planung.TimeItemArea.PointToClient(MousePosition))
 
If Not selectedTI Is Nothing Then
     
MsgBox(selectedTI.GanttRow.GridNode.GetCell(0).Content.Value + ” Start:” + selectedTI.Start.ToString())
 
End If

Leave a Reply