Mouse right in textbox

258 Views Asked by At

I everyone,

I have development this application, ... my objective is user, if click on right side of the mouse the url is paste to textbox.

MenuStrip

But when i click in right side, appear the menustrip of textbox. My question is I can disable this "menustrip"?!?

I send my code at the moment:

private void TxtUrl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
                TxtUrl.Paste();

        }
1

There are 1 best solutions below

1
AudioBubble On

This should work for your code:

    private MouseButtons e_Button = new MouseButtons();
    private void TxtUrl_MouseDown(object sender, MouseEventArgs e)
    {
        e_Button = e.Button;

        if (e.Button == System.Windows.Forms.MouseButtons.Right)
            TxtUrl.Paste();
    }

    private void cms_Opening(object sender, CancelEventArgs e)
    {
        if (e_Button == System.Windows.Forms.MouseButtons.Right)
            e.Cancel = true;
    }