Lucifer
Lucifer

Reputation: 1600

how to assign backspace as back key

I am Designing a windows form in which there is a picturebox which has back arrow image how to assign backspace key as direct shortcut to going back on previous form when current control is on form

Upvotes: 0

Views: 491

Answers (1)

Wudge
Wudge

Reputation: 357

Set the form property KeyPreview = true;. Then use the KeyDown-Event of the picturebox like this

private void picturebox1_KeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.Back) this.Close();
}

Upvotes: 6

Related Questions