Home - Forums-.NET - FlyGrid.Net (Windows Forms) - ContextMenuStrip on rows and columns?

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

ContextMenuStrip on rows and columns?
Link Posted: 13-Dec-2005 12:21
I'm evaluating FlyGrid 1.2.10 in a WinForms 2.0 app. I put a ContextMenuStrip in my form and added it to the FlyGrid.ContextMenuStrip property. That works fine. When I try to set it to a Column.ContextMenu, it does not recognize my existing ContextMenuStrip. Also, I cannot find any way to add a CMS to a Node (row). What I want is the same context for the whole grid. Am I missing something, or is this a missing feature (or a bug)?

Cheers,

Kevin
Link Posted: 13-Dec-2005 20:03
This not bug, the main problem in that we're trying to make FlyGrid to be compatible with all .Net runtimes and ContextMenuStrip is the new class, that have no general with ContextMenu base classes or implemented interfaces to combine ContextMenuStrip and ContextMenu in one property. FlyGrid.Net is supports ContextMenuStrip as System.Windows.Forms.Control inheritor, Column as inheritor of Component can't natively combine these properties.
Bit I think, that this problem will solved in the nearest FlyGrid.Net versions.
Now you can use following code to show contextMenuStrip that depends from various FlyGrid.Net contexts (this example shows how to determine where is the mouse cursor to show different context menu):
[C#]
private void InitGrid(FlyGrid flyGrid)
{
  //initilalization code
  //....
  //connect to FlyGrid.Mouseup event handler
  flyGrid.MouseUp += new System.Windows.Forms.MouseEventHandler(flyGrid_MouseUp);
}

//MouseUp event handler
private void flyGrid_MouseUp(object sender, MouseEventArgs e)
{
  if (e.Button == MouseButtons.Right)
  {
    Point hit = new Point(e.X, e.Y);
    HitTestInfo hi = flyGrid1.GetHitTestInfoAt(hit);
    hit = flyGrid1.PointToScreen(hit);//convert point to screen coords
    if (hi.HitTest == HitTest.OnColumnHeader)
    {
      if (hi.Col == 0)
        firstColContextMenu.Show(hit);
      else
        secondColContextMenu.Show(hit);
    }
    else if (hi.HitTest == HitTest.OnColumnHeader)
    {
      rowHeadersContextMenu.Show(hit);
    }
  }
}