Winforms Checkbox Focus Problem if no Text is Applied on Checkbox

checkbox, focus, winforms

Solution

The problem is that when a check box gets focus it highlights only the text portion of the control which is empty in your case. You have a few choices:

1) For all your "blank" text boxes, set the text property to a space. This will create a small highlighted portion when you tab to the control.

2) Program the OnEnter and OnLeave events of the checkbox, and draw/paint a square around the whole control.

3) If you want the default MouseEnter behaviour which creates a yellowish highlight on the check box itself, create your own check box control as follows:

public class MyCB : CheckBox
{
    protected override void OnEnter(EventArgs e)
    {
      base.OnEnter(e);
      base.OnMouseEnter(e);
    }

    protected override void OnLeave(EventArgs e)
    {
      base.OnLeave(e);
      base.OnMouseLeave(e);
    }
}

Problem

I have a multiple checkboxes on a Winforms without having the Text Property of all checkboxes, so the problem is that when i hover a mouse on the checkbox it highlighted but when i go to the checkbox using tab key it never get highlighted.. If anyone have the similar issue and already solved it Please help..

Original source