Question
Hi,
I am trying to evaluate Gantt chart control for use in few of our WEB projects.
I am glad to see that most of my requirements are fulfilled by GTP control. However there is one requirement to show details of Task in ToolTip for each of the timelines. I would like to know how to do it. A code snipped would help.
GridNode gn2 = gn.SubNodes.AddNode();
gn2.GetCell(0).Content.Value = dr[0];
TimeItem tj = GanttRow.FromGridNode(gn2).Layers[0].AddNewTimeItem();
tj.Start = DateTime.Parse(dt1.Rows[0][“mStatusValidFromDate”].ToString()).AddDays(5);
tj.Stop = tj.Start.AddMonths(6);
tj.TimeItemLayout = new TimeItemLayout();
tj.TimeItemLayout.Color = Color.Red;
tj.TimeItemLayout.TimeItemStyle = TimeItemStyle.Square;
tj.TimeItemLayout.TopInset = 20;
tj.ToolTip = “My details”; //Is it possible to do something like this.
Answer
We have choosen to not include any special handling of tooltips in GTP.NET, instead we urge you to use the standard ToolTip control for .NET and bring it up in a event. This way you can also provide dynamic information and not only fixed texts.
A good example of this is in the Gantt_TimeItems sample in the general download. It goes like this :
private void gantt1_OnTimeItem_Hoover(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)
{
string newTooltipText="";
if (e.TimeItem!=null)
{
newTooltipText="You are pointing at a time item that start "+e.TimeItem.Start.ToLongDateString();
if (e.TimeItem.UserReference is BreakInfo)
newTooltipText=newTooltipText+"\n The time item you are pointing on has a BreakInfo object in UserReference...";
}
else
{
newTooltipText="";
}
if (gantt1.MouseMoveKind==MouseMoveKind.move)
{
newTooltipText="You are moving a time item to the new date "+gantt1.FocusedTimeItem.Start.Add(e.Diff).ToLongDateString();
if (!(gantt1.GanttRowFromPoint(new Point(e.x,e.y)) == gantt1.FocusedTimeItem.Layer.Layers.GanttRow))
{
newTooltipText="You are moving a time item to a different row";
if (e.Diff.Days!=0)
newTooltipText=newTooltipText+"\n and to the new date "+gantt1.FocusedTimeItem.Start.Add(e.Diff).ToLongDateString();
}
}
else
if (gantt1.MouseMoveKind==MouseMoveKind.resizew)
{
newTooltipText="You are changing the start time of a time item to the new date "+gantt1.FocusedTimeItem.Start.Add(e.Diff).ToLongDateString();
}
else
if (gantt1.MouseMoveKind==MouseMoveKind.resizee)
{
newTooltipText="You are changing the stop time of a time item to the new date "+gantt1.FocusedTimeItem.Stop.Add(e.Diff).ToLongDateString();
}
if (toolTip1.GetToolTip(gantt1.TimeItemArea)!=newTooltipText)
toolTip1.SetToolTip(gantt1.TimeItemArea,newTooltipText);
}
This sample shows dynamic tooltips, but if you need Static, just add a string to the TimeItem.UserReference and pick it up in this event