1

I have one Windows form, which has multiple labels and picture box control. The current code is working fine but I need to set focus on the label and picture box on the tab keypress of the keyboard. I have tried multiple ways but not getting any solution for it.

Hardik
  • 79
  • 5
  • Neither `Label` nor `PictureBox` can have focus. Exactly what problem are you trying to solve by doing that? In other words, what do you want to happen after said controls take focus? For example, if you want them to respond to keystrokes, see [this post](https://stackoverflow.com/q/8874098/8967612). – 41686d6564 stands w. Palestine Jan 27 '21 at 21:29
  • Do you mean highlighting or showing active?? – Pavan Chandaka Jan 27 '21 at 21:30
  • If you want to make a PicureBox or Panel selectable, build a Custom Control that inherits from one of those classes and add `SetStyle(ControlStyles.Selectable | ControlStyles.UserMouse | ControlStyles.StandardClick, True);` in its constructor. Override `OnPaint()` and draw a border when the control `ContainsFocus` (you can override the `OnEnter()` / `OnLeave()` methods for this and re-route `OnMouseEnter()` / `OnMouseLeave(`). – Jimi Jan 27 '21 at 21:38
  • Yes, I need to highlight or showing activity for these 2 control. – Hardik Jan 27 '21 at 21:38

0 Answers0