When a button is focused by pressing Tab key, a rectangle appears on
it. Even if the button's TabStop property is set to false, when the
button is clicked with mouse the rectangle appears. Is it possible to
stop the rectangle from appearing? Please help. Regards.

This is because the focus still on the button.

On the button click event, you can set the focus to another control to 'remove' the rectangle

Hope this helps.

its a default styling in visual studio. it shows the button has the focus

Hi,

You can do it like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     TextBox1.Focus()
     ' put your code for the button click event here
End Sub

Move focus to other controls in that form

class CustomButton : System.Windows.Forms.Button
   {
       private bool _DisplayFocusCues = true;
       protected override bool ShowFocusCues
       {
           get
           {
               return _DisplayFocusCues;
           }
       }

       public bool DisplayFocusCues
       {
           get
           {
               return _DisplayFocusCues;
           }
           set
           {
               _DisplayFocusCues = value;
           }
       }
   }

Using this class you can set DisplayFocusCues at design time too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.