10813 : Is it possible to cancel OnGridCellChanged events?

Question

I am using C#, Windows application.
Is it possible to cancel OnGridCellSelectChanged events?
I have a popup form that says do you wish to change yes/no, is there a way to cancel this event?

CODE:

private void gantt1_OnGridCellSelectChanged(Cell cell, CellSelectChangedEventArgs cellSelectChanged)
{
  bool temp;
  submitcancel SCForm = new submitcancel();
  SCForm.ShowDialog();
  temp = SCForm.getStatus();

  if(temp) {
    //continue}
  else {
    //ignore event

  }

}

Answer

The event fires when changes occur in the Selected property of the Cell. So in princip you will get one call when the first cell is unselected and another call when the new cell is selected.

To null out the action here you can simply toggle the Select value back; cell.Selected = ! cellSelectChanged.NowSelected //( possible recursive problem?)

But I think that you want to make sure that the Grid.GridStructure.FocusedCell is not changed, so something like this:

    private void grid1_OnBeforeFocusedCellChange(PlexityHide.GTP.Grid grid, BeforeFocusedCellChangeEventArgs beforeFocusChange)
    {
      // This event allows you do control when cells are focused (when user moves with click or arrow keys)
      if (beforeFocusChange.OldFocusedCell!=null && beforeFocusChange.NewFocusedCell!=null)
      {
        if (beforeFocusChange.OldFocusedCell.Column.Index==2 && beforeFocusChange.NewFocusedCell.Column.Index==1)
        {
          // For some reason I do want the user to be able to move backwards from cell2 to cell1 horizontally
          beforeFocusChange.NewFocusedCell=beforeFocusChange.OldFocusedCell;
        }
      }
    }

 

10600 : Making sure the Gantt is not expanded after load

Question

I am using GTP.NET 2.3.1.
I fill my Gantt with DataBinding on several DataTables. This I’m doing in CGantt_OnNodeInserted(..).
I have Root_Nodes und Sub_Notes in my grid.
I’m tying to set
e.GridNode.Expanded = false;
or
//e.GridNode.Expand(false,true);
at the end of this Event-Handler.
But all my rows are expanded when I see the ganttchart for the first time.
What can I do that the tree is for the first view not expanded.
I have defined a button to expand or collapse my view, this is working fine.
What can I do ?
Is there a event that fires when all gridnodes are created before the gantt is shown ?

Answer

It is better to check if this new node is a child node, and if so to fold the parent.

if (e.GridNode.Parent!=null)
{
   e.GridNode.Parent.Expanded=false;
}

 

10593 : How do I obtain the (Grid) Node that was double-clicked?

Question

How do I obtain the (Grid) Node that was double-clicked?

I’ve tried a few things including:

 void GanttView_OnGridDoubleClick(object sender, EventArgs e)
    {
      Point p = PointToClient(MousePosition);
      Cell c = this.Grid.GridStructure.CellFromXY(p.X,p.Y);
      if (c != null)
      {
      }
  
    }

The cell returned is always null, I have a double-click handler on the timeitemarea and I’m able to locate the correct TimeItem no problem..

Answer

Your code is correct but the PointToClient translates to Gantt-coords and not grid coords. change to this:

      Point p = this.Grid.PointToClient(MousePosition);

10523 : The TimeItem Rectangle

Question

I have userdrawn timeitems that are smaller (shorter in height) than the standard timeitem rectangle (rect). When connecting timeitemlinks, the links attach below the userdrawn timeitem. How do I force the rect dimensions to the same or similar dimensions of the userdrawn timeitem so that timeitemlink attach directly to the timeitem? Thanks

Answer

You can control the “thickness” of a time item by setting the Inset properties of the TimeItemLayout. BottomInset  and TopInset. These values are given in percent, so to make the time item rectangle 10 percent thinner from the top you would set TimeItemLayout.TopInset=10, and to shave 10 percent of the original height from the bottom you set TimeItemLayout.BottomInset=10.

 

 

10498 : Gantt_ASP interaction

Question

I’m working with GTP.NET for ASP.NET10 trial version, which I downloaded directly from your site. I’m trying to enable both the horizontally drag&drop and the resizing of a timeitem, but when I click on the timeitem, the gantt is only refreshed and nothing remains selected.

Furthermore, if I try to move a timeitem (holding the left-click and moving the mouse), the “unavailable pointer” sing appears, and the gantt doesn’t do nothing (it doesn’t even do the refresh).

I also attached events for “OnTimeItem_BeforeMove” and “OnTimeItem_AfterMove”, but the only event intercepted is the “OnTimeItem_ClientClick”

How can I enable drag&drop?

Please note that I almost copied the code from the help downloaded from your site.

Answer

Many of the interaction events from windows forms are disabled in Gantt_ASP. The Gantt_ASP produces strict html and uses postbacks to handle user events. To get full interaction you need to include the windows forms assembly in your web page. Or you can bring up new windows and get text information from the user on new values for a time item etc (this you need to do yourself).

We are working on an Ajax enabled Gantt wrapper that will give you some user interaction without postbacks but this is not finished (no date).

10491 : How can I specify the text color of a selected cell?

Question

I have a question concerning the CellLayouts class.

How can I specify the text color of a selected cell? I miss a SelectedFontColor property in the CellLayouts class. There are BackgroundColor, SelectedColor and FontColor however the text color of a selected cell is always white.

Answer

Correct. This is something of an oversight. Based on your finding we added a new property to CellLayout called FontColorSelected that controls the font color on a selected cell.

Please contact support if you need this update asap (we have it in the lab). Also please state if you use VS2005 or 2003.

 

10481 : Is there a way to get the current resolution of the DateScaler?

Question

Is there a way to get the current resolution of the DateScaler? I found the Resolution parameter in the OnDateScalerDrawString event but how can I get the Resolution value without using a member variable?

Answer

In the latest service release we have added two new properties; BackgroundScaleFactor and FishEyeScaleFactor exposed on the Gantt.DateScaler to give access to this information.

10471 : Scrolling faster

Question

Instead of panning left and right a little bit at a time, I want one click on the pan buttons to move forward the distance X where X = gantt.datescaler.stop – gantt.datescaler.start.
In other words, if your current zoom level is showing 2 days, I want a click on one of those buttons to move forward another two days.

Thanks!

Answer

Go like this:


    private void buttonJumpLongerInScroll_Click(object sender, System.EventArgs e)
    {
     
      gantt1.DateScaler.OnBeforeScaleOrSpanChange+=new BeforeScaleOrSpanChangeEventHandler(DateScaler_OnBeforeScaleOrSpanChange);

    }
    
    private void DateScaler_OnBeforeScaleOrSpanChange(DateScaler dateScaler, BeforeScaleOrSpanChangeArgs e)
    {
      if (!e.IsZoom)
      {
        TimeSpan jumptime=dateScaler.StopTime.Subtract(dateScaler.StartTime);
        if (e.NewStartTime<dateScaler.StartTime)
        {
          e.NewStartTime=dateScaler.StartTime.Subtract(jumptime);
          e.NewStopTime=dateScaler.StopTime.Subtract(jumptime);
        }
        else
        {
          e.NewStartTime=dateScaler.StartTime.Add(jumptime);
          e.NewStopTime=dateScaler.StopTime.Add(jumptime);
        
        }
      }
    }

10433 : Readonly cells

Question

Id like to to prevent a user from editing grid cells.  The only way Ive been able to do this is set:

GridNode.GridControl.Enabled = false

Unfortunately this also prevents the user from scrolling the grid.  Is there a way where I can leave the grid control enabled, but prevent the user from changing the text in the nodes?

Answer

Yes, that is not the recommended approach. Instead you should implement the OnBeforeEditCell event, and set the e.editAllowed=false, it will do the trick much better.

And also it will allow you to evaluate the cell so that it can be made editable under certain dynamic circumstances that you decide.

If you want to dis-allow edit all together you can simple set the GridColumns[x].Readonly=true.