如何设定/更改/删除在C#中的按钮焦点风格? [英] How to set/change/remove focus style on a Button in C#?
问题描述
我有一对夫妇,其中我修改了他们如何看的按钮。我已经将它们设置为平面按钮与背景和自定义边框,使他们看起来都pretty并没有什么像正常按钮了(实际上,他们现在看起来像Office 2003的按钮;-)。所述按钮具有一个像素的边界
I have a couple of buttons of which I modified how they look. I have set them as flat buttons with a background and a custom border so they look all pretty and nothing like normal buttons anymore (actually, they look like Office 2003 buttons now ;-). The buttons have a border of one pixel.
然而,当按钮被选中的按钮突然变得和额外边框周围的同一颜色的(或者通过点击或键盘的动作像pressing Tab键获得焦点),所以使它成为一个两象素边境。此外,当我关闭一个像素边框,按钮没有得到焦点一像素宽的边框。
However when the button gets selected (gets the focus through either a click or a keyboard action like pressing the tab key) the button suddenly gets and extra border around it of the same colour, so making it a two pixel border. Moreover when I disable the one pixel border, the button does not get a one pixel border on focus.
在网上这个问题是问了很多像我怎么能在一个按钮来禁止专注',但是这不是我想要的:焦点仍应存在的,只是没有的显示的在现在这样的方式。
On the net this question is asked a lot like 'How can I disable focus on a Button', but that's not what I want: the focus should still exist, just not display in the way it does now.
有什么建议? : - )
Any suggestions? :-)
推荐答案
这是你要找的影响吗?
public class NoFocusCueButton : Button
{
protected override bool ShowFocusCues
{
get
{
return false;
}
}
}
您可以使用此自定义按钮就像一个普通的按钮,但它不会给你一个焦点矩形额外
You can use this custom button class just like a regular button, but it won't give you an extra rectangle on focus.
这篇关于如何设定/更改/删除在C#中的按钮焦点风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!