Replace button with Enter key

Hello everyone,

i have a question, i have made a little program for my boss, but theres 1 modification i need to make within 1 hour and 20 minutes.

my problem is:

i have a button "Enter" which calls this function:
void Form1::button1_Click(System::Object^ sender, System::EventArgs^ e){

int generatedPercent = rand() % 101;
//rand() % 101;
this->pictureBox1->Visible = false;
this->pictureBox2->Visible = false;
if(generatedPercent > RedPercent){
this->pictureBox1->Visible = true;
}
else{
this->pictureBox2->Visible = true;
}
}

i would like that when i press the "Enter" key on my pc keyboard, i call this function, so it practically does the same as the button in my program.

is this possible, and can anyone make this for me?

Thanks alot! i really appriciate it!
This should go to Windows Programming. Anyways - it is possible, but depending on what you want to do not such a good idea. First of all - is this a professional application? If so, why the heck is this button called button1? And the form Form1? Seriously? Anyways: You can override the OnKeyDown method of your form (not of your button - else the event is only handled if the button is focused) to call the buttons PerformClick method.
Topic archived. No new replies allowed.