pankaj kumar singh
pankaj kumar singh

Reputation: 17

how can we add KeyUp event for the LABEL controls

Is there any way to add KeyUp event for the LABEL control? Just like TextChanged event. We have found KeyUp Property for the TEXTBOX control. KeyUp property of the TEXTBOX control available on the "Property window", but for the LABEL control it is not available.

So, Please suggest me that how can we add KeyUp property on the LABEL control.

Thanks & Regards

pankajsingh

Upvotes: 0

Views: 287

Answers (3)

Randy
Randy

Reputation: 2348

As other's have pointed out, there is no KeyUp event for a Label control.

Having said that, you could use a TextBox under the hood and make it look like a Label and then wire up the KeyUp event.

Be sure to set these properties...

TextBox Properties

TextBox Properties

And here's what it would look like.

enter image description here

Upvotes: 0

rory.ap
rory.ap

Reputation: 35260

You can't even get focus on a label (it has no accessible TabStop property that you can set to true, and by default, it does not receive input). Therefore, this question doesn't make any sense. There's no way to get any key-related events from a label.

Upvotes: 1

Johnie Karr
Johnie Karr

Reputation: 2822

You won't be able to do this. Label controls don't capture keyboard focus, so therefore, there aren't any keyboard events you can listen for.

Upvotes: 1

Related Questions