10184 : How to select the item (row) in the grid that corresponds to an item in the gantt area that is selected ? (i.e in the same row)

Question

How to select the item (row) in the grid that corresponds to an item in the gantt area that is selected ? (i.e in the same row)

Answer

In GTP.NET you implement the event Gantt.OnTimeItem_SelectionChanged and put some code there like:

if (e.TimeItem.Selected)
  Gantt.Grid.GridStructure.FocusedCell=e.TimeItem.GanttRow.GridNode.GetCell(0);

In phGantTimePackage the event is called IphGantX3.OnSelectionChangedGantTime, and the code would look like this

if (theDataEntity.Selected)
  IphGantX3.GridCellFocusedY=(theDataEntity.Row.TreeNode as IphDataEntity_Tree3).GridRowIndex;

10185 : More information displayed while resizing/moving a TimeItem

Question

I evaluate your product GTP.NET 2.0. Is it possible to get more information displayed while resizing/moving a TimeItem like a tooltip for the editing DateTime and a vertical line over the TimeItemArea which displays the currently position of the new DateTime? It would be great when the steps of the vertical line would go synchron to the currently displayed DateScalar.

Answer

Currently there is nothing built in that you just can switch on, we will probably add something to meet this popular demand. But you can implement tooltips (look in the sample called Gantt_TimeItems) and you could also draw a line using the OnTimeItemAreaPaintBackground Event.

 

10220 : Is there a way to remove the horizontal scrollbar on the grid?

Question

Is there a way to remove the horizontal scrollbar on the grid?
This is a great chart.

Answer

The horizontal grid scroll will be shown whenever the sum of all non hidden column widths is greater than the grid width. Currently the only way to avoid showing the horizontal scroll is to hide or resize specific columns so that the visible columns all fit within the grid width.

10175 : How can I insert Sub-nodes when using the gantt control in data-bound mode?

Question

How can I  insert Sub-nodes when using the gantt control in data-bound mode?

Answer

If the subnodes should be databound as well you can do it like this:

  private void gantt1_OnNodeInserted(PlexityHide.GTP.Grid aGrid, PlexityHide.GTP.NodeEventArgs e)
  {
  
   object row=e.GridNode.ListItemWhenDataBound();
   object val=e.GridNode.OwningCollection.NodeDataConnect.CurrencyManager.GetItemProperties().Find(“id”,true).GetValue(row);

   // Set up tree using DataViews, in this sample we only allow for SubLevel zero (root nodes) to have sub nodes
   if (e.GridNode.SubLevel==0)
   {
    DataView subNodeView = new DataView(dataSet21.project);
    if (val is Int32)
     subNodeView.RowFilter=”ownedby=”+val.ToString();
    else
     subNodeView.RowFilter=”ownedby=-1″;
     // Set the SubNodes to bind to the subNodeView
    e.GridNode.SubNodes_DataSourceList=subNodeView;
   }
  }

10172 : Can you help me, to disable any drag or change time in the gantt area.

Question

Can you help me, to disable any drag  or change time in the gant area. I want to give the editing outside the phgant. I don’t want the users to edit the time or the row of the Gantt.

Answer

In phGantTimePackage this can be handled with properties on the IphGantRow3.

IphGantRow3.TimeItems_CanChangeRow=false
IphGantRow3.TimeItems_CanMove=false
IphGantRow3.TimeItems_CanResize

In the GTP.NET 2.0 you have even better control; you set properties on the TimeItemLayout:

 AllowChangeRow  Limits the degrees of freedom available to user 
 AllowLinkReAssignStart  Controls if link re-assign can be done for the start of a link 
 AllowLinkReAssignTarget  Controls if link re-assign can be done for the target of a link 
 AllowLinkSelectionStart  Controls if link selection can be done for the start of a link 
 AllowLinkSelectionTarget  Controls if link selection can be done for the targer of a link 
 AllowMove  Limits the degrees of freedom available to user 
 AllowResizeEast  Limits the degrees of freedom available to user 
 AllowResizeWest  Limits the degrees of freedom available to user 

10163 : How can I check that text size (in pixels) are exceeding the column width (in pixles).

Question

I am showing tooltip on mouse over on a grid cell by using following code:

    Private Sub gantt1_OnGridMouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Gantt1.OnGridMouseMove
        Try
            Dim cell As cell = Gantt1.Grid.GridStructure.CellFromXY(e.X, e.Y)
            Dim tooltiptext As String = “”
            If Not cell Is Nothing Then
                If Not cell.Content.UserReference Is Nothing Then
                    tooltiptext = cell.Content.UserReference
                End If
            End If
            Me.TimelineTip.Active = True
            Me.TimelineTip.SetToolTip(Gantt1.Grid, tooltiptext)
        Catch ex As Exception
            GetLogger(Me).Error(ex)
        End Try
    End Sub

Question: This display tooltip on desired cells perfectly but now I want to show tooltip ONLY when the node text in the cell is not fit within. In other words I want to show tooltip ONLY when cell text is not completely visible and have to resize column to see alll text. How can I check that text size (in pixels) are exceeding the column width (in pixles).

Answer

You can meassure the text and compare it to the Grid.Width;

// Get handle to form.
IntPtr hwnd = new IntPtr();
hwnd = thisForm.Handle;
// Create new graphics object using handle to window.
Graphics newGraphics = Graphics.FromHwnd(hwnd);

SizeF textSize = new SizeF();
textSize=newGraphics.MeasureString(Cell.Content.Value,Cell.Layout.Font);

// Dispose of new graphics.
newGraphics.Dispose();

Note: it will probably be a good idea to get the hwnd, or even the Graphics object, one time and keep it, and not ask for it for every measure…

 

10158 : Scrollbar in Gantt_ASP

Question

we are using Your GTP in an ASP.NET application. It works fine, but there is one problem: not all the time and grid items are shown in the visible area…and there are no vertical scroll bars!!! How can I enable vertical scrolling? Thank You for Your quick answer 🙂

Answer

The Gantt_ASP produces pure html, to show a scrollbar you can add the Gantt_ASP to inline frame and use the frames scrollbar. Another solution is to page the data on several pages. The 2.0 version (available in early May) has paging built in, in the 1.3 version you can set the Gantt.Grid.GridStructure.TopNode to control where the Gantt_ASP begins its drawing.

 

10160 : How can I fill a comboBox for a Column?

Question

I must provide custom values from DB to a grid columm, so my users can choose one. This list can change over time.
VCL edition.
Thanks.

Answer

The inplace-edit-combobox often must have different values depending on what column or row it pops up.

There is an event that fires just before the edit starts. In this event you may change the content in the combobox depending on focused cell.

In the phGantTimePackage OCX this event is called IphGantX3.OnBeforeCanEditGrid
You the call IphGantX3.GridEditComboClear and IphGantX3.GridEditComboAdd

In the phGantTimePackage VCL this event is called phGant.Grid.OnEditorCanModify, but there is another event that only fires when a combo edit is started: phGant.Grid.OnBeforeEditWithCombo.
You can then use phGant.Grid.InitEditCombo to update values

In GTP.NET the event is called Gantt.Grid.OnBeforeEditCell, and you can fill the combobox with data like this:

private void grid1_OnBeforeEditCell(PlexityHide.GTP.Grid grid, PlexityHide.GTP.BeforeEditEventArgs beforeEdit)
{

  if (beforeEdit.Cell.Content is ComboText)
  {
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Clear();
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 1”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 2”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 3”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 4”);
  }

}

 

10156 : I would like to get rid of the grid in one of my gantt charts (I want it to be all chart, no grid).

Question

I would like to get rid of the grid in one of my gantt charts (I want it to be all chart, no grid).  If I set the width of the grid to 0, the gantt instance starts throwing exceptions.  What is the best way to make the grid invisible?

Answer

True, the grid need to indicate row heights. What you should do is to hi-jack the grid-control and put it somewhere else, out of sight…

Like this:

private void HideGrid_Click(object sender, System.EventArgs e)
{
  gantt1.Grid.Parent=panel1;
}

10157 : denormalized table

Question

One of my dataset-bound gantt charts has a RootNode_DataSource of a table for employee shifts.  Unfortunately this table is denormalized to the point where the name of the position the employee is in for the shift is not available in this table (only the position id).  In the grid I would like to list the position name.

Answer

I cannot see why the performance should suffer from this, other than the fact that you will do one look up for each row… If this look up includes a server round trip it will probably be slow, but that has very little to do with the GTP.NET.

I suggest that you either formulate your query so that the resulting result set contains the name in each row (join on the table with the name) or prepare a better look-up method that does not need a server roundtrip