选项​​卡上的C#的WinForms删除按钮边框

选项​​卡上的C#的WinForms删除按钮边框

本文介绍了选项​​卡上的C#的WinForms删除按钮边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的表单上的按钮已经平样式应用,并使用背景图片,我已删除按钮的所有边界,但是当我到标签从另一个控制周围出现按钮黑色边框的按钮。

I have a button on my form that has flat style applied and uses a background image, I have removed all borders from the button, but when I tab onto the button from another control a black border appears around the button.

这可以在下面的图片中可以看出。在左边是右边的黑色边框的按钮是不同的按钮,但显示了取消按钮的外观。

This can be seen in the image below. On the left is the button with black border on the right is a different button but shows how the cancel button should look.

推荐答案

我没有得到这个边界,如果我设置了 BoderSize 0 FlatAppearance 部分。

I do not get this border, if I set the BoderSize to 0 in the FlatAppearance section.

进一步的调查表明,只有当按钮是默认按钮会出现这条边界。你可以创建自己的按钮,它从来没有表现出这条边界类似这样

Further investigation shows that this border appears only when the button is the default button. You can create your own button, which does never show this border like this

public class NoNotifyButton: System.Windows.Forms.Button
{
    public override void NotifyDefault(bool value)
    {
    }
}

注意: NotifyDefault 仍有意空

这篇关于选项​​卡上的C#的WinForms删除按钮边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:47