The procedure associated with the KeyPress event has . . . . . . . . parameters.

2
3
4
1

The correct answer is D. 1.

The KeyPress event is raised when a key is pressed on the keyboard. The procedure associated with the KeyPress event has one parameter, which is of type KeyPressEventArgs. The KeyPressEventArgs class has two properties: KeyChar and Modifiers.

The KeyChar property contains the character that was pressed. The Modifiers property contains a bitmask that indicates which modifier keys were pressed, such as Shift, Ctrl, or Alt.

For example, the following code shows how to handle the KeyPress event:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 'A')
{
MessageBox.Show("You pressed the A key");
}
}

In this example, the KeyPress event is handled by the textBox1_KeyPress event handler. The event handler checks the KeyChar property to see if the A key was pressed. If it was, the MessageBox.Show method is used to display a message box.

Exit mobile version