Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could Label get a focus?

I have a one question on my university's test about C#. Could label get a focus? As I can see on MSDN site, all Controls can get a focus, but some of them aren't selectable. So it's seems to me that the right answer is "Label could get a focus, but couldn't be selected". Also Label has a Focus() method. Please, help me understand. Thanx.

like image 420
Frankie Drake Avatar asked Apr 17 '11 09:04

Frankie Drake


1 Answers

Yes there is a Focus() method on Label and yes it is absolutely right it works; but behave differently. let me try to explain

A Label can be associated with some one input control, for instance a label for a user name text field, so there is concept of Associated Control with the label. AssociatedControlID on msdn

So you can associate an input control with a label and whenever label is selected the control passed to the associated input control.

Example here click on Email or Password labels in login box and see what happened, similarly if you call focus method on the label the focus will passed to the associated control.

like image 152
Waqas Raja Avatar answered Sep 24 '22 03:09

Waqas Raja