Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting ctrl+left click on winforms application

How do I detect when the users holds ctrl and left clicks on a button in a windows forms application?

like image 542
Suriyan Suresh Avatar asked Sep 17 '09 14:09

Suriyan Suresh


1 Answers

You need to check the value of Form.ModifierKeys to see if Control was pressed, e.g.:

    btn.Click += new EventHandler(btn_Click);

    private void btn_Click(object sender, EventArgs e)
    {
        if (Form.ModifierKeys == Keys.Control)
        {
            // Do Ctrl-Left Click Work
        }
    }
like image 145
JDunkerley Avatar answered Oct 22 '22 13:10

JDunkerley