按钮周围的浅蓝色边框 [英] light blue border around button

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

问题描述

在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?

推荐答案

我认为没有一个简单的属性(有人可能会纠正我),但你可以使用Paint事件。 / p>

I don't think there's a simple property for that (someone might correct me), but you can use the Paint event.

      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));
         }
      }


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆