Using .NET 4 you can use something as simple as:
private void Control_DoubleClick(object sender, EventArgs e)
{
if (ModifierKeys.HasFlag(Keys.Control))
{
MessageBox.Show("Ctrl is pressed!");
}
}
If you're not using .NET 4, then the availability of Enum.HasFlag
is revoked, but to achieve the same result in previous versions:
private void CustomFormControl_DoubleClick(object sender, EventArgs e)
{
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
MessageBox.Show("Ctrl is pressed!");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…