Right-click Popup

1

I'm trying to make a popup by right-clicking inside a GridView .

I am using the event MouseDown and the event MouseUp to make popupControlContainer appear and disappear.

But how would you make it appear where the mouse is?

In search, I found here in StackOverFlow these two questions, however they are for WPF and I'm working with Winforms:

Options menu with right-click on datagrid

Options menu with right-click selected row in datagrid

I also found this question, but for .NET component, I need it for DevExpress:

#> link

Event code MouseDown and MouseUp

 private void click_right(object sender, MouseEventArgs e) // click com o botao do mouse direto em cima do grid view
    {
        if (e.Button == MouseButtons.Right) // botao direito
        {
            popupControlContainer1.Show();
        }
    }

    private void upclick_right(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Right) // botao direito
        {
            popupControlContainer1.Hide();
        }
    }
    
asked by anonymous 06.09.2016 / 16:06

1 answer

1

I was able to deploy using the MouseDown event of the GridView , along with the ContextMenuStrip component

ContextMenuStrip Documentation

 private void MyDataGridView_MouseDown(object sender, MouseEventArgs e)
    {
        // verifica se o item esta em edição ou se é um item novo
        if(editar == 1 || nCRM == 0)
        {
            // verifica se é com o botão equerdo
            if (e.Button == MouseButtons.Right)
            {
                // exibe o ContesteMenuStrip na posição do mouse dentro do gridcontrol
                CRM.Show(gridControl1.PointToScreen(new Point(e.X, e.Y)));
            }
        }
    }
    
06.09.2016 / 17:07