Where to define the menu items event handler
<p>I have a DataGridView on a WinForm.  When the user right-click on the grid, I am showing a popup menu. There are 3 kinds of popup menu according to where the right-click has been done:</p>

<ol>
<li>on a row that is defined as readonly</li>
<li>on a row that can be edited</li>
<li>on any other place in the grid (rowindex is -1)</li>
</ol>

<p>I created a new classes to manage the popup menus generation.</p>

<pre><code>public class GridPopupMenuFactory
{
    public ContextMenu GetMenu(int rowIndex, bool isReadOnlyRow)
    {
        BaseMenu _menu = null;

        switch (rowIndex)
        {
            case -1:
                _menu = new GeneralMenu();
                break;
            default:
                if (isReadOnlyRow)
                {
                    _menu = new ReadonlyRowMenu();
                }
                else
                {
                    _menu = new EditableRowMenu();
                }
                break;
        }

        return _menu.Menu;
    }
}

public abstract class BaseMenu
{
    protected ContextMenu _menu;
    public ContextMenu Menu
    {
        get
        {
            if (_menu.MenuItems.Count == 0)
            {
                GenerateMenu();
            }
            return _menu;
        }
    }

    protected abstract void GenerateMenu();
}

public class GeneralMenu : BaseMenu
{
    protected override void GenerateMenu()
    {
        var contextMenu = new ContextMenu();

        contextMenu.MenuItems.Add(new MenuItem("Sort"));
        contextMenu.MenuItems.Add(new MenuItem("Print"));            

        _menu = contextMenu;
    }
}

public class ReadonlyRowMenu : BaseMenu
{
    protected override void GenerateMenu()
    {
        var contextMenu = new ContextMenu();

        contextMenu.MenuItems.Add(new MenuItem("View"));            

        _menu = contextMenu;
    }
}

public class EditableRowMenu : BaseMenu
{
    protected override void GenerateMenu()
    {
        var contextMenu = new ContextMenu();

        contextMenu.MenuItems.Add(new MenuItem("Add"));
        contextMenu.MenuItems.Add(new MenuItem("Edit"));
        contextMenu.MenuItems.Add(new MenuItem("Delete"));

        _menu = contextMenu;
    }
}

// Winform
private void shipmentDetailsDataGridView_MouseClick(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Right)
        {
            var rowIndex = shipmentDetailsDataGridView.HitTest(e.X, e.Y).RowIndex;
            var popupMenu = GridPopupMenu.GetMenu(rowIndex, false);  // 2nd parameter can be true, TODO

            popupMenu.Show(shipmentDetailsDataGridView, new Point(e.X, e.Y));
        }
    }
</code></pre>

<p>My question is where is the correct place to define the event handler for each one of the menu items?</p>

<p>Update:
After clicking on the menu item, the whole operation is done on the DataGridView itself.
For example, clicking on add, will open a temp form with all the required field and then this information will be added as a new row in the DataGridView.</p>