C#, mouseClickEvent doesn't respond to right mouse click

Alex Kapustian picture Alex Kapustian · Jun 24, 2010 · Viewed 8.2k times · Source

on click event doesn't respond to right mouse click. The event is for a richTextBox. when I try the same code on the form it works fine.

what could be the problem?

EDIT: I use winforms

Answer

shookdiesel picture shookdiesel · Jun 24, 2010

You need to check it on the MouseDown event.

private void TextBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
        wasRightButtonClicked = true;
}