如何在“鼠标悬停"和“鼠标离开"上删除Win窗体中标准按钮的边框. [英] How to remove border of a Standard Button in Win form On Mouse Over and Mouse Leave.
问题描述
大家好,
我正在将FlatStyle = System.Windows.Forms.FlatStyle.Standard
与Button一起使用.现在的问题是,我使用的是正在跳舞的图像,并且按钮边框在鼠标进入和鼠标离开的时间上也发生了变化.
我不知道如何解决此问题,也不知道如何将Button边框颜色设置为宽度为1的灰色.
在此先感谢.
Hi All,
I am using a Button with FlatStyle = System.Windows.Forms.FlatStyle.Standard
. Now the problem is in this I am using an Image which is dancing and button border is also changing on Mouse Enter and Mouse Leave time.
I don''t know how to fix this problem and also how to make the Button border color as gray with a width of 1.
Thanks in advance.
推荐答案
尝试像这样设置属性:
this.myButton.FlatAppearance.BorderSize = 0;
Try setting the property like so:
this.myButton.FlatAppearance.BorderSize = 0;
简单的方法是..
Hi,
The simple way would be ..
class BorderlessButton:Button
{
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
pevent.Graphics.DrawRectangle(new Pen(this.BackColor,5), this.ClientRectangle);
}
}
一旦您编译了该类.它会在工具框中可用.拖动以形成表格.设置平面样式.显示您的图像.
Once you compile this class. it will be available in the tool box. Drag to form. Set flat style. Display your image.
AFAIK更改标准"按钮边框的唯一方法是自己绘制图像.这也是克服Image问题的最佳方法.
所有者-绘制按钮 [
AFAIK 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.
Owner-draw button[^] is a good example from here on the Code Project.
If you don''t like that one there are loads of other examples on the web just search on owner draw button.
这篇关于如何在“鼠标悬停"和“鼠标离开"上删除Win窗体中标准按钮的边框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!