Visual C# Designating a Windows Forms LABEL as the Accept Button

188 Views Asked by At

I try to Designate the Accept Button property from my form to the click event of a label. If I would have used a button this wouldn't have been a problem but I have chosen to use a label for UI reasons.

Unfortunaly the Accept Button property only accept a button, so I have already tried to place a button on my form, make this button the acceptbutton and call the label_Click method when the button click_event is fired.

This worked like a charm but when I made the visibility property of my button false or made my button Hide() after the InitializeComponent() the Accept Button didn't worked anymore.

How Can the Accept Button property accept a label OR how can I visually hide a button without changing its visibility property?

Edit: a visualisation of what I tried to acomplish. When the enter is pressed on the form (Accept Button property), I want to invoke the same method when the Play label is clicked. Visualisation

1

There are 1 best solutions below

0
Mifo On BEST ANSWER

To make the button "disappear" without hiding it you can change the border to 0, change the background color to the same color as the form and for FlatStyle property choose Flat. You could also use an image for the button background that is the same color as your form.