It might be easier just to make it a TextBox
, set the BorderStyle
to None
, set the BackColor
to Control
and set ReadOnly
to True
. This should give the appearance of a label, but still allow it to be tabbed onto for focus.
Update It looks like with a combination of SetStyle(ControlStyles.Selectable, true);
and TabStop = true;
, you can get the Label to focus using the Tab key. Below is a simple example that shows it working:
public class SelectableLabel : Label
{
public SelectableLabel()
{
SetStyle(ControlStyles.Selectable, true);
TabStop = true;
}
protected override void OnEnter(EventArgs e)
{
BackColor = Color.Red;
base.OnEnter(e);
}
protected override void OnLeave(EventArgs e)
{
BackColor = SystemColors.Control;
base.OnLeave(e);
}
protected override void OnMouseDown(MouseEventArgs e)
{
this.Focus();
base.OnMouseDown(e);
}
}