Control.ModifierKeys 属性

定义

获取一个表示哪个修改键(Shift、Ctrl 和 Alt)处于按下状态的值。

C#
public static System.Windows.Forms.Keys ModifierKeys { get; }

属性值

Keys

Keys 值的按位组合。 默认值为 None

示例

下面的代码示例在单击按钮时按下 Ctrl 键时隐藏按钮。 此示例要求你在 Button button1 a Form.

C#
private void button1_Click(object sender, System.EventArgs e)
{
   /* If the CTRL key is pressed when the 
      * control is clicked, hide the control. */
   if(Control.ModifierKeys == Keys.Control)
   {
      ((Control)sender).Hide();
   }
}

适用于

产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅