Skip to content

How highlight a win forms checkbox when cursor is inside it

Saurav Gurjar

Saurav Gurjar

Asked Nov 29, 2018, 2:10 AM EST1 answer
Share
LinkedInX

I have some checkbox with no text specified. Now whenever I tab down to this checkbox, it does not get highlighted. How to get it highlighted so that user can know that the cursor is there in checkbox.

 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Saurav Gurjar
    0
    application design pade code. 
      
    C#
    this.activstats.GotFocus += new System.EventHandler(this.checkBox_Highlight);
    this.activstats.LostFocus += new System.EventHandler(this.checkBox_EndHighlight);
    this.chknige.GotFocus += new System.EventHandler(this.checkBox_Highlight);
    this.chknige.LostFocus += new System.EventHandler(this.checkBox_EndHighlight);
     
    Application .cs file code.
     
    TypeScript
    private void checkBox_Highlight(object sender, EventArgs e)
    {
    CheckBox control = (CheckBox)sender;
    control.FlatStyle = FlatStyle.Flat;
    control.ForeColor = Color.Red;
    }
    
    private void checkBox_EndHighlight(object sender, EventArgs e)
    {
    CheckBox control = (CheckBox)sender;
    if (!control.Focused)
    {
    control.ForeColor = DefaultForeColor;
    }
    }
     
     
    0