vb.net 单击时隐藏按钮的边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21793859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide button's border when click
提问by elvinguitar
In my program, when I clicked the "question mark button" it shows another form as shown in the image below. But the button's border is shown, how can I make it transparent?

在我的程序中,当我单击“问号按钮”时,它会显示另一种形式,如下图所示。但是显示了按钮的边框,如何使其透明?

采纳答案by Vignesh Kumar A
You can try this
你可以试试这个
testButton.TabStop = false
testButton.FlatStyle = FlatStyle.Flat
testButton.FlatAppearance.BorderSize = 0
testButton.FlatAppearance.BorderColor = Color.White
testButton.FlatAppearance.CheckedBackColor = Color.White
testButton.FlatAppearance.MouseDownBackColor = Color.White
testButton.FlatAppearance.MouseOverBackColor = Color.White
回答by ???ěxě?
The only way to alter the border of a 'standard' button is to draw it yourself. This would also be the best way to overcome your problems with the Image. Or you can set the flat appearance as below...
改变“标准”按钮边框的唯一方法是自己绘制它。这也是克服图像问题的最佳方法。或者您可以设置平面外观如下...
Me.button1.FlatAppearance.BorderSize = 0
You can do this on the load event if you want.
如果需要,您可以在加载事件上执行此操作。
回答by Mickael Delorme
Had the same issue :
有同样的问题:
- "BorderSize = 0" couldn't solve
- Setting BorderColor to a solid brush was not applicable since my BackGround was a custom bitmap. The BorderColor would have been visible anyway.
- “BorderSize = 0”无法解决
- 将 BorderColor 设置为实心画笔不适用,因为我的 BackGround 是自定义位图。无论如何,BorderColor 都是可见的。
Trying to "root cause" the annoying border though : the border is due to the focus still being somehow set on the button while the DialogBox is displayed.
虽然试图“根本原因”恼人的边框:边框是由于在显示 DialogBox 时焦点仍以某种方式设置在按钮上。
Do you follow me ?...
你听懂了吗 ?...
So all you have to do is move the focus away... before opening your DialogBox. Example below :
因此,您所要做的就是在打开对话框之前将焦点移开……。下面的例子:
TextBox1.focus()
Dim result As DialogResult = frmMyDialog.ShowDialog(Me)
That did the trick for me ;)
那对我有用;)
HTH
HTH
Mickael Delorme
迈克尔·德洛姆
Merry X-Mas, Pepita !
圣诞快乐,佩皮塔!

