Home - Forums-.NET - FlyGrid.Net (Windows Forms) - How to Enable/Add LinkLabel like HotTracking

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

How to Enable/Add LinkLabel like HotTracking
Link Posted: 14-Aug-2007 12:07
What is the best way to add HotTracking to a column that is not an HierarchicalColumn.  The grid I'm working with is in virtual mode.

I do not want to use the EditorStyle.Dialog.  I want similar behavior as if it was a LinkLabel in the column.

Thanks,
Mark
Link Posted: 15-Aug-2007 01:42
Mark,

Currently, the only HierarchyColumn implements hot tracking support.

The second option is to implement a custom node that would repaint itself when mouse is over node.
Link Posted: 15-Aug-2007 02:40
Ok, thanks, I managed to come up with a solution by inheriting from NumberColumn.  I'd post the code, but its fairly lengthy and keeps getting cut off when I post it.   So here are the key parts:


    public override Columns Owner
    {
      get { return base.Owner; }
      set
      {
        if ( value != base.Owner )
        {
          if ( base.Owner != null && hotTrack ) DeregisterHotTrackEvents( this.GetGrid() );

          base.Owner = value;

          if ( hotTrack ) RegisterHotTrackEvents( this.GetGrid() );
        }
      }
    }
    private void flyGrid_MouseMove( object sender, MouseEventArgs e )
    {
      FlyGrid grid = (FlyGrid) sender;

      if ( lastHotTrackedNode != null )
      {
        NodeBase tmp = lastHotTrackedNode;
        tmp.HotTrack = false;
        lastHotTrackedNode = null;
        grid.InvalidateCell( tmp, this );
      }

      HitTestInfo hi = grid.GetHitTestInfoAt( e.Location );

      if ( ( hi.HitTest & HitTest.OnNode ) != 0 && hi.Col != -1 && hi.Row != -1 && grid.Columns.VisibleColumns[hi.Col] == this )
      {
        NodeBase nb = hi.port.Rows.GetNodeFromRow( hi.Row );

        if ( nb.Depth == hotTrackNodeDepth )
        {
          lastHotTrackedNode = nb;
          lastHotTrackedNode.HotTrack = true;
          hi.port.InvalidateNode( lastHotTrackedNode );
        }
      }
    }

    protected override void PaintTextInCell( CellDrawInfo dci, Brush bkBrush, Color foreColor )
    {
      if ( hotTrack && lastHotTrackedNode == dci.node )
        dci.Font = new Font( dci.Font, ( dci.Font.Style | FontStyle.Underline ) );

      base.PaintTextInCell( dci, bkBrush, foreColor );
    }
Link Posted: 15-Aug-2007 06:16
Thanks for the code, Mark.