visual basic.net中的无边界按钮



嘿,我在问如何在vb.net中制作一个无边界按钮,我总是可以将样式设置为平坦,并使背景颜色透明,但我总是让按钮集中并显示在按钮的形状中,这破坏了我想要的按钮样式这是我之前用过的一个类,但是它不起作用

Public Class ButtonEx
Inherits Button
    Private _ShouldShowFocus As Boolean = False
    Public Property ShouldShowFocus() As Boolean
        Get
            Return _ShouldShowFocus
        End Get
        Set(ByVal value As Boolean)
            _ShouldShowFocus = value
        End Set
    End Property
    Protected Overrides ReadOnly Property ShowFocusCues() As Boolean
        Get
            Return _ShouldShowFocus
        End Get
    End Property
End Class

您可以子类化标准按钮并覆盖OnPaint方法来实现无边界按钮。

Class BorderlessButton
Inherits Button
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
    MyBase.OnPaint(pe)
    pe.Graphics.DrawRectangle(New Pen(BackColor, 5), ClientRectangle)
End Sub
End Class

我假设你已经尝试了Button.FlatAppearance属性,但这些都不能帮助解决你的问题。

Public Class ButtonNoFocusCues
    Inherits System.Windows.Forms.Button
    Protected Overrides ReadOnly Property ShowFocusCues As Boolean
        Get
            Return False
        End Get
    End Property
End Class

你可以使用可点击的标签,这样就没有边框了只需添加悬停代码.....

如果你使用的是asp.net
,你也可以使用bootstrap或css

最新更新