Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Show Context Menu for Grouped Rows in FlexGrid

Background:

We can show the context menu in FlexGrid using the ContextMenuStrip property, but there is no specific property that allows us to directly show the context menu for specific rows like grouped rows. To show the context menu directly for grouped rows in FlexGrid, you’ll need to handle the MouseDown event as given below. Note, this process is only for grouped rows.

Steps to Complete:

  1. Create a ContextMenuStrip and add the desired items.

    ContextMenuStrip contextMenuStrip1 = new ContextMenuStrip;
    contextMenuStrip1.Items.Add("Item1");
    contextMenuStrip1.Items.Add("Item2");
    contextMenuStrip1.Items.Add("Item3");
    contextMenuStrip1.Items.Add("Item4");
  2. Handle the MouseDown event to show the context menu for grouped rows.

    private void C1FlexGrid1_MouseDown(object sender, MouseEventArgs e)
    {
        HitTestInfo ht = c1FlexGrid1.HitTest(e.X, e.Y);
        if (ht.Type == HitTestTypeEnum.Cell)
        {
            if (c1FlexGrid1.Rows[ht.Row].IsNode && e.Button == MouseButtons.Right && ht.Column == 1)
            {
              contextMenuStrip1.Show(c1FlexGrid1.PointToScreen(new Point(e.X, e.Y)));
            }
        }
    }
Get the Latest Version of C1
Download the Free Trial Now