Popup when right-clicking mouse

Asked

Viewed 1,858 times

1

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

I’m using the event MouseDown and the event MouseUp to do the popupControlContainer appear and disappear.

but how to make it appear where the mouse is?

In research, I found here at Stackoverflow these two questions, but they are for WPF and I am working with Winforms:

Right-click options menu in datagrid

Right-click options menu selected in datagrid

I also found this question, however it is for component . NET, need for Devexpress:

https://stackoverflow.com/questions/3035144/right-click-to-select-a-row-in-a-datagridview-and-show-a-menu-to-delete-it

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();
        }
    }
  • 1

    What is popupControlContainer1?

  • @jbueno follows documentation: https://documentation.devexpress.com/#Windowsforms/clsDevExpressXtraBarsPopupControlContainertopic

  • @stderr thanks I’ll read.

1 answer

1


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

Documentation of the Contextmenustrip

 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)));
            }
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.