Reputation: 815
Is this possible to do or are you only allowed to .focus one textbox on each form? I'm looking to highlight more than one textbox at one time if data is empty.
Upvotes: 1
Views: 140
Reputation:
Only one control can have the focus every time (and thus what you request is not possible). In any case, note that the focus is meant for actions (not for visuals) and that only one control can perform actions every time in the GUI thread (e.g., text written in a TextBox
or Button
being clicked). On the other hand, you might provoke situations similar-enough to various controls getting the focus simultaneously (e.g., text written in various textboxes, coordinated via TextChanged Events
: the actions are not performed simultaneously but the user will not realise about it).
If your intention is just highlighting the given control, you shouldn't rely on the focus. The focused control does get somehow highlighted, although this visual effect is not too relevant and, some times, not even perceptible. The best thing you can do is provoking the highlighting effect "manually". For example: Panel
surrounding the TextBox
, whose dimensions/visibility are affected; or just simply changing the BackColor
property of the TextBox
.
Upvotes: 2