如何在vb.net中制作自定义按钮

时间:2010-09-18 05:05:48

标签: vb.net visual-studio-2008 interface

你知道任何可以帮助我在vb.net中制作自定义按钮的教程吗?因为visual studio 2008不允许您创建圆形或三角形的按钮。我已经尝试过搜索并找到了这个但是,我无法使用它因为有很多错误。 http://www.codeproject.com/KB/buttons/CButton.aspx

2 个答案:

答案 0 :(得分:2)

您可以使用WPF创建任何形状的Button。

请参阅以下网址

http://www.codeproject.com/KB/WPF/glassbuttons.aspx

答案 1 :(得分:-1)

创建各种形状的自定义按钮非常简单, 将图片框添加到表单后,这是基本代码(picHome):

    Private Sub picHome_Click(sender As System.Object, e As System.EventArgs) Handles picHome.Click
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MOver
            lbMsg.Text = "HOME BUTTON CLICKED"
        Catch ex As Exception

        End Try
    End Sub

    Private Sub picHome_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles picHome.MouseDown
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MClick
        Catch ex As Exception

        End Try
    End Sub

    Private Sub picHome_MouseEnter(sender As Object, e As System.EventArgs) Handles picHome.MouseEnter
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MOver
            lbMsg.Text = "MOUSE OVER HOME BUTTON"
        Catch ex As Exception

        End Try
    End Sub

如果您在此处发布任何问题,请观看此视频教程https://www.youtube.com/watch?v=989M3qYrlKo