0

嘿,我在问如何在 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
4

3 回答 3

1

您可以继承标准按钮并覆盖 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属性,但这些都无助于解决您的问题。

于 2013-05-18T23:45:55.050 回答
1
Public Class ButtonNoFocusCues
    Inherits System.Windows.Forms.Button
    Protected Overrides ReadOnly Property ShowFocusCues As Boolean
        Get
            Return False
        End Get
    End Property
End Class
于 2015-06-09T21:24:10.157 回答
0

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

如果您使用 asp.net,您也可以使用 bootstrap 或 css

于 2013-10-08T07:22:57.427 回答