本文介绍了按钮周围的浅蓝色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Winforms中,看起来像焦点的按钮有一个浅蓝色边框。

In Winforms, it looks like the button which has focus has a light blue border.

在我的表单中有两个按钮,当表单首次加载时,button1有焦点并有一个浅蓝色边框。

In my form which has two buttons, when the form first loads, button1 has focus and has a light blue border.

点击button2后,它有一个浅蓝色边框。

After I click on button2, it then has a light blue border.

我可以将淡蓝色更改为其他颜色吗?

Can I change the light blue to a different color?

推荐答案

      private void button1_Paint(object sender, PaintEventArgs e)
      {
         Button b = sender as Button;
         if (b.Focused)
         {
            e.Graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(e.ClipRectangle.Left, e.ClipRectangle.Top, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1));
         }
      }


这篇关于按钮周围的浅蓝色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 22:24