1
Good evening or good morning depending on where you live I was wondering if any of you could tell me how to open a new form when pressed at the same time alt + F4
1
Good evening or good morning depending on where you live I was wondering if any of you could tell me how to open a new form when pressed at the same time alt + F4
0
To open a new form by clicking alt+F4
:
Form 1:
Set the property KeyPreview
as true
;
this.KeyPreview = true;
Sign the Keydown Event;
this.KeyDown += Form1_KeyDown;
Complete;
public Form1()
{
InitializeComponent();
this.KeyPreview = true;
this.KeyDown += Form1_KeyDown;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.Alt&&e.KeyCode==Keys.F4)
{
Form2 form2 = new Form2();
form2.Show();
e.Handled = true;
}
}
Important
Set the property
e.Handled = true;
to prevent Form 2 close.
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
PQ you want to use Alt+F4 to open a new form, surely 99.9% of applications use Alt+F4 to close the form.
– Pablo Tondolo de Vargas
I’m doing alt F4 and that’s what I’m going to use to move to the next level no one will suspect
– Pekita
@Pekira, it has not yet become clear the meaning of using this feature, as Pablo Vargas said himself, this feature is used to close the form. Can explain better what the purpose of this resource ?
– Diego Farias