-1

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

call-me
  • 686
  • 9
  • 18
  • Crystal ball says that you used PerformClick (why do we have to guess??). It does not click when the control is disabled or hidden. It is not very clear why you insist on using the AcceptButton property, given that you don't have any use for its benefits, you can simply call this.Close() or assign the DialogResult property in the label's Click event handler. – Hans Passant May 16 '16 at 20:19
  • I might have explained it wrong, and made an edit wich hopefully clearified my question, also I didn't used PerformClick , and don't know what this.close() has to do with this. – call-me May 16 '16 at 20:36

1 Answers1

0

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.

Mifo
  • 563
  • 6
  • 6