Control.ModifierKeys 属性

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

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Shared ReadOnly Property ModifierKeys As Keys
用法
Dim value As Keys

value = Control.ModifierKeys
public static Keys ModifierKeys { get; }
public:
static property Keys ModifierKeys {
    Keys get ();
}
/** @property */
public static Keys get_ModifierKeys ()
public static function get ModifierKeys () : Keys

属性值

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

示例

下面的代码示例在单击某按钮的同时按 Ctrl 键时隐藏该按钮。该示例要求在 Form 有一个名为 button1Button

Private Sub button1_Click(sender As Object, _
  e As EventArgs) Handles button1.Click
   ' If the CTRL key is pressed when the 
   ' control is clicked, hide the control. 
   If Control.ModifierKeys = Keys.Control Then
      CType(sender, Control).Hide()
   End If
End Sub
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();
   }
}
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 )
      {
         (dynamic_cast<Control^>(sender))->Hide();
      }
   }
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.get_ModifierKeys().Equals(Keys.Control)) {
        ((Control)sender).Hide();
    }
} //button1_Click

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Control 类
Control 成员
System.Windows.Forms 命名空间
Keys